Env::Array - Perl module that "imports" environment variables as arrays
With explicit delimiters:
use Env::Array qw(PATH :); use Env::Array qw(@MANPATH :);
With inferred delimiters:
use Env::Array qw(@LD_LIBRARY_PATH);
The Env::Array Perl module allows environment variables to be treated as Perl array variables, analogous to the way the Env module allows them to be treated as scalar variables.
Env::Array
Env
The Env::Array::import() function requires pairs of environment variable names and delimiter strings to be presented in the use statement. If just one argument is given, then $Config::Config{path_sep} is taken as the delimiter. Env::Array allows the variable name to have the '@' array type prefix, if desired. The variable being tied must otherwise begin with a letter. Unlike Env, Env::Array does nothing if the use list is empty.
use
$Config::Config{path_sep}
@
After an environment variable is tied, just use it like an ordinary array. Bear in mind, however, that each access to the variable requires splitting the string anew.
The code:
use Env::Array qw(@PATH); push @PATH, '.';
is equivalent to:
use Env qw(PATH); $PATH .= ":.";
except that the Env::Array approach does the right thing for both Unix-like operating systems and for Win32. Also, if $ENV{PATH} was the empty string, the Env approach leaves it with the (odd) value ":.", but the Env::Array approach leaves it with ".".
$ENV{PATH}
:.
.
Env::Array requires Perl 5.005 or later for proper operation due to its use of tied arrays.
The Env Perl module.
Gregor N. Purdy <gregor@focusresearch.com>
Copyright (C) 1999-2000 Gregor N. Purdy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Env::Array, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Env::Array
CPAN shell
perl -MCPAN -e shell install Env::Array
For more information on module installation, please visit the detailed CPAN module installation guide.