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.

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 (Abbot) 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.