constant::override - Override/ignore constants
use constant::override ignore => [ 'SO_CONFIG_FILE' ], substitute => { 'MYCONST1' => 1, 'MYCONST2' => sub { 2 } }; use constant SO_CONFIG_FILE => 100; use constant MYCONST1 => 200; use constant MYCONST2 => 300; eval { SO_CONFIG_FILE() }; # Undefined function error. print MYCONST1,"\n"; # 1. print MYCONST2,"\n"; # 2.
Provides for overriding constant's import method, so that the 'constant' functions can be replaced with your own functions/values, or ignored altogether.
constant
use constant::override ... statements must occur before use constant ... statements.
use constant::override ...
use constant ...
Takes a hash of arguments:
An arrayref of constant names (may be package-qualified). Any subsequent attempt to define a constant with this name will be silently ignored.
A hashref mapping from constant name (may be package-qualified) to either a scalar value or a coderef. Any subsequent attempt to define a constant with that name will cause the constant to map to either the specified coderef, or a coderef that returns the specified scalar value.
Package-qualified constants are preferred to bare constants, and substituting a constant is preferred to ignoring a constant, when determining what to do on subsequent calls to import.
import
Please report any bugs or feature requests to bug-constant-override at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=constant-override.
bug-constant-override at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc constant::override
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=constant-override
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/constant-override
CPAN Ratings
http://cpanratings.perl.org/d/constant-override
Search CPAN
http://search.cpan.org/dist/constant-override/
Tom Harrison APNIC Software, C<< <cpan at apnic.net> >>
Copyright 2013 APNIC Pty Ltd.
This library is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
The full text of the license can be found in the LICENSE file included with this module.
To install constant::override, copy and paste the appropriate command in to your terminal.
cpanm
cpanm constant::override
CPAN shell
perl -MCPAN -e shell install constant::override
For more information on module installation, please visit the detailed CPAN module installation guide.