NAME
Env::Array - Perl module that "imports" environment variables as arrays
SYNOPSIS
With explicit delimiters:
use Env::Array qw(PATH :);
use Env::Array qw(@MANPATH :);
With inferred delimiters:
use Env::Array qw(@LD_LIBRARY_PATH);
DESCRIPTION
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.
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.
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::Array
requires Perl 5.005 or later for proper operation due to its use of tied arrays.
SEE ALSO
The Env
Perl module.
AUTHOR
Gregor N. Purdy <gregor@focusresearch.com>
COPYRIGHT
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.