NAME

constant::tiny - Perl pragma to declare constants

SYNOPSIS

use constant::tiny;
use constant PI    => 4 * atan2(1, 1);
use constant DEBUG => 0;

print "Pi equals ", PI, "...\n" if DEBUG;

DESCRIPTION

This module is a lightweight version of Perl standard constant.pm. Here are the keys differences:

  • only works on Perl 5.10+ in order to simplify a good part of the code

  • doesn't support Unicode name; please use the standard constant.pm module if you need to create constants with Unicode names

  • stricter rules about valid names; standard constant.pm gives 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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc constant::tiny

You can also look for information at:

BUGS

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.

ACKNOWLEDGEMENTS

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.

AUTHOR

Sébastien Aperghis-Tramoni <sebastien at aperghis.net>

LICENSE

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.