Env::Export - Export %ENV values as constant subroutines
use Env::Export qr/^PAR/; # This will fail at compile time if the $ENV{PAR_PROGNAME} # environment variable didn't exist: print PAR_PROGNAME, "\n"; # regular constant sub, works fully qualified, too! package Foo; print main::PAR_PROGNAME, "\n";
This module exports the requested environment variables from %ENV as constants, represented by subroutines that have the same names as the specific environment variables.
%ENV
Specification of the environment values to export may be by explicit name or by regular expression. Any number of names or patterns may be passed in.
Any environment variable whose name would be a valid Perl identifier (must match the pattern ^[A-Za-z_]\w*$ may be exported this way. No values are exported by default, all must be explicitly requested. If you request a name that does not match the above pattern, a warning is issued and the name is removed from the exports list.
^[A-Za-z_]\w*$
You can import all environment variables, if you really want to, by means of:
use Env::Export qr/./;
constant
Randy J. Ray <rjray@blackperl.com>
<rjray@blackperl.com>
Original idea from a journal posting by Curtis "Ovid" Poe (<ovid at cpan.org>), built on a sample implementation done by Steffen Mueller, <smueller@cpan.org>.
<ovid at cpan.org>
<smueller@cpan.org>
Please report any bugs or feature requests to bug-env-export at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Env-Export. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-env-export at rt.cpan.org
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Env-Export
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Env-Export
CPAN Ratings
http://cpanratings.perl.org/d/Env-Export
Search CPAN
http://search.cpan.org/dist/Env-Export
Source code on GitHub
http://github.com/rjray/env-export/tree/master
This file and the code within are copyright (c) 2009 by Randy J. Ray.
Copying and distribution are permitted under the terms of the Artistic License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php) or the GNU LGPL 2.1 (http://www.opensource.org/licenses/lgpl-2.1.php).
To install Env::Export, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Env::Export
CPAN shell
perl -MCPAN -e shell install Env::Export
For more information on module installation, please visit the detailed CPAN module installation guide.