Sure - Here is the script: ==================================================== #!/usr/local/bin/perl
$ENV{P} = "Hello World" ; print "\nEnvironment Variable P = $ENV{P}\n\n" ; print "In this shell type \'echo \$P\'\n" ; $pid = system("$ENV{SHELL}") ; waitpid($pid,0) ; print "\n$0 is now complete\n" ; ==================================================== And here is the output: ==================================================== :-> ./a.pl Environment Variable P = Hello World In this shell type 'echo $P' crumpf@ronin /home/crumpf :-> echo $P Hello World crumpf@ronin /home/crumpf :-> exit exit ./a.pl is now complete :-> ==================================================== Hope this helps. -Chris -----Original Message----- From: Torbjørn Lindahl [mailto:lindahl@;stud.ntnu.no] Sent: Wednesday, November 06, 2002 2:10 PM To: [EMAIL PROTECTED] Subject: RE: [Perl-unix-users] setting environmental variables Could you show me a working example of this? Regards, Torbjørn Lindahl On Wed, 6 Nov 2002, Rumpf, Christopher wrote: > I got around it one by cheating (hack). > > I set the env variable...then just spawned $ENV{SHELL} which inherits > the var you set earlier - and then just waited for the pid of the > spawned SHELL process to return before exiting the perl script. > > Just an idea which may work for you. > > Gl. > > -Chris > > -----Original Message----- > From: Bayard Bell [mailto:Bayard.G.Bell@;morganstanley.com] > Sent: Wednesday, November 06, 2002 1:38 PM > To: Torbjørn Lindahl > Cc: [EMAIL PROTECTED] > Subject: Re: [Perl-unix-users] setting environmental variables > > > This can't work. Perl is running as a child process. Parents can't > inherit the environments of their children. Environment settings can > only be propagated to children. > > Torbjørn Lindahl wrote: > > > > Hi list, > > > > how can I set an environmental variable from within perl - so that > > it will be valid after the perl script has completed as well? > > > > i have done the following... > > > > $ENV{'MY_ENV_VAR'}="Some value"; > > > > ...and in shell... > > > > echo $MY_ENV_VAR > > > > ...but no good. > > > > I also tried... > > > > system("export MY_ENV_VAR='Some value'"); > > > > ...but didnt work either. > > > > Regards, > > Torbjørn Lindahl > > > > _______________________________________________ > > Perl-Unix-Users mailing list > > [EMAIL PROTECTED] > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ > Perl-Unix-Users mailing list [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs