-
-
16 Aug 2015 20:33:53 UTC
- Distribution: constant-tiny
- Module version: 1.02
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (1)
- Testers (664 / 21 / 18)
- Kwalitee
Bus factor: 0- 100.00% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (8.01KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Sebastien Aperghis-Tramoni
- Dependencies
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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 the Perl standard module
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 names; please use the standard
constant.pm
module if you need to create constants with Unicode namesstricter rules about valid names, only allow names with alphanums (
[a-zA-Z0-9]
and underscore (_
), allowing one optional leading underscore
In order to simplify its usage,
constant:tiny
uses the normalconstant
API. The main advatange is that switching your code toconstant::tiny
means simply adding it before the firstuse constant
. The disadvantage is that, obviously, both modules can't be used at the same time. If the normalconstant
was loaded beforeconstant::tiny
, the latter won't do anything, letting the normalconstant
do the work.Other than this, the usage is (nearly) exactly the same as with the standard
constant
module. For more details, please read constant.Rationale
The original reason to write this module was that, starting with version 1.24,
constant
always loaded utf8_heavy.pl, which consumes some memory. Usually, this is not problematic, but in some particular cases (embedded Perl, frequently forked programs à la CGI), the increased memory cost can become a concern.Therefore, this module was written as a alternative solution, with no support for Unicode names, so that programs working in memory constrained environments could have a better control.
Funnily enough, the day
constant::tiny
was released on CPAN (the code had been written two months earlier as a proof of concept), Brad Gilbert proposed a patch forconstant
in order to delay loading utf8_heavy.pl until necessary.Therefore
constant::tiny
is less useful (which is good news), but can still address specific needs, if you want to restrict constant names to alphanums only.SUPPORT
You can find documentation for this module with the perldoc command.
perldoc constant::tiny
You can also look for information at:
Search CPAN
Meta CPAN
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/Public/Dist/Display.html?Name=constant-tiny.
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
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.
Module Install Instructions
To install constant::tiny, copy and paste the appropriate command in to your terminal.
cpanm constant::tiny
perl -MCPAN -e shell install constant::tiny
For more information on module installation, please visit the detailed CPAN module installation guide.