Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

manipulating environment variables

by opensourcer (Monk)
on Apr 22, 2010 at 10:58 UTC ( #836222=perlquestion: print w/ replies, xml ) Need Help??
opensourcer has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
How do I manipulate ENV variable, example:
MYConfig.pm ------- %MCONF = ( NAME => 'SOURCER', JOB => 'BATCH', );
and I want to use MCONF hash keys NAME and JOB in another script or module as $ENV{NAME}.
Thanks.

Comment on manipulating environment variables
Download Code
Re: manipulating environment variables
by almut (Canon) on Apr 22, 2010 at 11:28 UTC
    for my $name (keys %MCONF) { $ENV{$name} = $MCONF{$name}; }

    (but note that this only has an effect for the current process and its subprocesses)

Re: manipulating environment variables
by zwon (Monsignor) on Apr 22, 2010 at 11:35 UTC

    You can assign values to %ENV the same way you assigning values to usual hash. If other script is child of current process created after you assigned value to $ENV{NAME}, the value will be available in this script. If other script is not child of the current process, than you should use some other way to pass value to it, there's no practical way one process could change environment of the other process.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://836222]
Approved by ahmad
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-10-30 13:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls