Env

By | August 12, 2010

Perl provides access to environment variables via the global "%ENV" hash. However, if using the ENV module, it will create global scalars for all the environment variables.

use Env;
print “$USER uses $SHELL”;

If required to get only a few selected variables then it can be done like:

use Env qw[@PATH $USER];
print "$USER's path is @PATH";

Leave a Reply

Your email address will not be published. Required fields are marked *