Hi all,
I have a perl script which declares two variables and calls another perl script which accesses those variables. But I am unable to access the variables in the called script. My script is as follows:
my $ENV{a}="20";
system("perl called.pl");
and my called.pl contains:
print "$ENV{a}\n";
My problem is that a variable declaration script reads the values from a config file and then I calll that variable declaration script from my main script which access the variables. I am declaring all the variables as Environment variables.
Please help me.
Thanks,
guru
It works for me. Try remove the "my".
Hi,
I have a variables script which reads a config file and assigns it to environment variables.
I have main script which uses those environment variables. Here inmain script when i call the variables script, its unable to read the variables:
like
variable script:
$ENV{a};
then in my main script i call
system{"perl variables.pl");
print "$ENV{a}\n;
I am unable to access those values.
Please help
As I said, I used exactly the same case you provided but I got the result you asked for. I'm not sure what your problem is exactly.
[bernardchan@bernardchan shm]$ cat a.pl
$ENV{a}="20";
system("perl called.pl");
[bernardchan@bernardchan shm]$ cat called.pl
print "$ENV{a}\n";
[bernardchan@bernardchan shm]$ perl -w a.pl
20