Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 8.45 EnglishChapter 8
Standard Modules
Next: 8.47 Errno
 

8.46 Env

Lets your program treat environment variables as simple variables instead of having to access them from the %ENV pseudo-hash where they are kept.

use Env;

use Env qw(var1 var2 ...);
Internally, Env uses an import function that ties suitably named environment variables to global Perl variables with the same names. By default, it ties all variables yielded by keys %ENV. A "suitable" environment has a name that begins with an alphabetic character and contains only alphanumeric characters or underscores.

When use Env is invoked with arguments, the arguments are interpreted as a list of environment variables to tie, but the variables don't have to exist yet. After a variable has been tied, you can use it like a normal variable, accessing or changing its value.

You untie a variable by setting its value to undef.


Previous: 8.45 EnglishPerl in a NutshellNext: 8.47 Errno
8.45 EnglishBook Index8.47 Errno