NAME

Env::Export - Export %ENV values as constant subroutines

SYNOPSIS

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"; 

DESCRIPTION

This module exports the requested environment variables from %ENV as constants, represented by subroutines that have the same names as the specific environment variables.

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.

EXPORT

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.

CAVEATS

You can import all environment variables, if you really want to, by means of:

use Env::Export qr/./;

SEE ALSO

constant

AUTHOR

Randy J. Ray <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>.

BUGS

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.

SUPPORT

COPYRIGHT & LICENSE

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).