constant::tiny - Perl pragma to declare constants
use constant::tiny; use constant PI => 4 * atan2(1, 1); use constant DEBUG => 0; print "Pi equals ", PI, "...\n" if DEBUG;
This module is a lightweight version of Perl standard
constant.pm. Here are the keys differences:
constant.pmmodule if you need to create constants with Unicode names
constant.pmgives more detailled diagnostics about why a given name is not valid
The rationale behind this module is that recent versions of
constant.pm have a better support for Unicode names. However, this means loading full Unicode support (utf8_heavy.pl) which consumes memory. In most cases, the difference is not problematic. But in some particular cases (embedded Perl, frequently forked programs a la CGI), the increased memory cost can become a concern. This is even more annoying if the program doesn't use Unicode at all and therefore pays the high price.
Hence this module, which provides a very simple solution, only requiring you to add
use constant::tiny before any declaration of constants.
Other than this, the usage is (nearly) exactly the same as with the standard
constant.pm module. For more details, please read constant.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Please report any bugs or feature requests to
contant-tiny at rt.cpan.org, or through the web interface at https://rt.cpan.org/Public/Dist/Display.html?Name=constant-tiny. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
This module is heavily based on
constant.pm, originaly written by Tom Phoenix, Casey West, Nicholas Clark, Zefram and many other folks from the Perl 5 Porters.
<sebastien at aperghis.net>
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.