Home > Archive > PERL Beginners > October 2005 > Perl - Add env,.variable?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Perl - Add env,.variable?
|
|
| gustav@varupiraten.se 2005-10-27, 9:55 pm |
| Hi there!
I want to add an environment variable in Perl. Is there any built-in
function for achieving this?
/G
@varupiraten.se
| |
| Paul Lalli 2005-10-27, 9:55 pm |
| gustav@varupiraten.se wrote:
> I want to add an environment variable in Perl. Is there any built-in
> function for achieving this?
If you want to set an environment variable for the currently executing
script, and any of its forked children, to use while that script is
running, simply modify the global %ENV hash. This hash is tied to all
the environment variables.
Note that you CANNOT change the environment of your script's parent
process.
See also:
perldoc -q environment
Paul Lalli
| |
| Thomas Bätzler 2005-10-27, 9:55 pm |
| <gustav@varupiraten.se> asked:
> I want to add an environment variable in Perl. Is there any
> built-in function for achieving this?
$ENV{'variablename'} = $value;
Just remember that you can't modify the environment of your
parent process, but only that of your own (sub-)process(es).
HTH,
Thomas
|
|
|
|
|