in reply to Re^2: Setting environment variables by reading them from a configuration file
in thread Setting environment variables by reading them from a configuration file
and$ENV{'PLATFORM'}="abcdef";
I'm noticing a lot of ugly style in your code, a lot of unnecessary code, but nothing that should stop it from working. The following works for me.$variable="PLATFORM"; $ENV{$variable}="abcdef";
In particular, you don't need to use "$variable", just $variable. You don't need to seek to the begining of a file handle you just opened. You don't need to chomp the components if you already chomped the variable they were split from. But none of that should really cause problems. Are you sure that your code is actually being run? That is, you've got the assignment to %ENV inside an if on your open. Do you have an else telling you if the open failed? Could you add code to print out $variable and $value when you're setting them to make sure they really have what you expect?use strict; if (@ARGV){ print $ENV{PLATFORM}, $/; exit; } while(<DATA>){ chomp; my ($variable, $value) = split '='; $ENV{$variable}=$value; } system("perl", $0, "test"); __DATA__ PLATFORM=abcdef
|
|---|