|
Posted by Dennis Roesler on February 21, 2008, 3:48 pm
Please log in for more thread options
pgodfrin wrote:
> ...snip...
>> Yes I'm aware of this - I think this is a scoping issue. So program A
>> loads the modules, and then calls it to set the environment values. I
>> only care for the variables set during that process, and any other
>> from the calling program. However, certain variables get set and
>> others are not set exactly right....
>>
I found the snippet of code inside this sub on the net somewhere and has
been tweaked for our use. I put it in a module that is library of
general purpose functions we use.
sub getEnv {
my $perlCommand = "perl -MData::Dumper -e 'print Dumper(\%ENV)';";
#my $sourceCommand = "/bin/ksh";
my $sourceCommand = "";
while(my $file = shift) {
carp("$file does not exist") && next unless(-e $file);
my $sourceLine = "$sourceCommand $file 1>&2";
my %tmp = %{eval('my ' . `. $sourceLine\n$perlCommand`)};
$ENV = $tmp for (keys %tmp);
}
}
Dennis
d underscore roesler at agilent dot com
|