wrote:
> Hi all I searched in google for this.But no solution is working.
> I am Ramesh working on perl.I am facing one problem in exporting an
> variable.
> Requirement:
> I have to export a new variable through a perl script.
> in brief :
> -->in vi editor i am able to export like below.
> export ram=20;
> --->If I want to see the variable: echo $ram
> giving 20 as the answer.But when I put the export commnad in perl
> script & giving "echo" on vi editor it doesn't giving the value
> associated with that environmental variable
You can't set environment variables for other processes from within
a program. Your programs environment is inherited from the process
that started it (perhaps the shell). Once the program is started its
environment is its private property, nothing than the program itself
can change it. So everything you can change from within a Perl script
is the environment of the script itself and, of course, the environ-
ments of the processes started afterwards from within the script
(since they inherit its environment). But it is simply not possible
to change the environment of any other program that is already run-
ning.
> I got the reason:
> I am giving export command in script like
> $ram=20;
> system("export ram");
That should probably be 'system("export $ram");'
> system command forking one more child process. So the value becomes
> temporary.
system() creates a shell, which then has that environment variable
being set. But that doesn't help you a bit, since it then quits
immediately.
> How can I come out of this problem.
You can't, sorry. The environment isn't what you seem to think it
is. It isn't a medium to exchange informations between processes.
Regards, Jens
--
\ Jens Thoms Toerring ___
\__________________________
http://toerring.de