in reply to Re: Setting Environment variables in Perl
in thread Setting Environment variables in Perl

Hi,

It works because $ENV gives you access to your current environment and child environments. Once your foo.pl ends your FOO will be gone.

Try executing foo.sh once more after foo.pl finishes. You'll see the value of FOO being empty.

--
if ( 1 ) { $postman->ring() for (1..2); }
  • Comment on Re^2: Setting Environment variables in Perl

Replies are listed 'Best First'.
Re^3: Setting Environment variables in Perl
by Random_Walk (Prior) on Sep 12, 2005 at 11:37 UTC

    The OP said:

    I have a situation where i have to set shell environment variables within perl script and invoke shell command which uses this environment variable using system() function.

    So the commands are being run from within the Perl script using system(). They will be children of the Perl and will inherit it's environment.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
Re^3: Setting Environment variables in Perl
by mhacker (Sexton) on Sep 13, 2005 at 07:07 UTC
    Yes, a process can never change the environment variables of a parent process, which is what would happen if FOO was still there when the script finished (a perl script runs in a child process from your shell). /Hacker