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

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:

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

Comment on manipulating environment variables
Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-12-02 01:33 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (31 votes), past polls