Env - perl module that imports environment variables as scalars or arrays
use Env; use Env qw(PATH HOME TERM); use Env qw($SHELL @LD_LIBRARY_PATH);
Perl maintains environment variables in a special hash named
After an environment variable is tied, merely use it like a normal variable. You may access its value
@path = split(/:/, $PATH); print join("\n", @LD_LIBRARY_PATH), "\n";
or modify it
$PATH .= ":."; push @LD_LIBRARY_PATH, $dir;
however you'd like. Bear in mind, however, that each access to a tied array variable requires splitting the environment variable's string anew.
use Env qw(@PATH); push @PATH, '.';
is equivalent to:
use Env qw(PATH); $PATH .= ":.";
except that if
To remove a tied environment variable from the environment, assign it the undefined value
undef $PATH; undef @LD_LIBRARY_PATH;
On VMS systems, arrays tied to environment variables are read-only. Attempting to change anything will cause a warning.