NAME
once - execute code only once throughout the program's lifetime
SYNOPSIS
sub setup {
my $self = shift;
ONCE {
print "run only once however often setup() is called"
};
# other_things();
}
DESCRIPTION
This module provides a way to run code only once, no matter how often the surrounding code is called.
METHODS
ONCE
-
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.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org.
INSTALLATION
See perlmodinstall for information and options on installing Perl modules.
AVAILABILITY
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://www.perl.com/CPAN/authors/id/M/MA/MARCEL/.
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.
AUTHORS
Marcel Grünauer, <marcel@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2009 by Marcel Grünauer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.