once - Execute code only once throughout the program's lifetime
version 1.101420
use once; sub setup { my $self = shift; ONCE { print "run only once however often setup() is called" }; # other_things(); }
This module provides a way to run code only once, no matter how often the surrounding code is called.
This subroutine is exported automatically. It takes a code block and executes it only the first time that this specific call of ONCE is encountered. This might be useful, for example, in a situation where you initialize an object but only want to do it the first time any object of that class is initialized, perhaps to install methods or setup some other data.
ONCE
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=once.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/once/.
The development version lives at http://github.com/hanekomu/once/. Instead of sending patches, please fork this project using the standard git and github infrastructure.
Marcel Gruenauer <marcel@cpan.org>
This software is copyright (c) 2009 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install once, copy and paste the appropriate command in to your terminal.
cpanm
cpanm once
CPAN shell
perl -MCPAN -e shell install once
For more information on module installation, please visit the detailed CPAN module installation guide.