Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way of setting an environment variable using a perl program in the shell which called the perl program? Thanks

Replies are listed 'Best First'.
Re: Setting environment variables
by eg (Friar) on Feb 09, 2001 at 23:49 UTC
Re: Setting environment variables
by Gloom (Monk) on Feb 09, 2001 at 23:47 UTC
    environment variables only can be inherited, a child can't set one for its parent ...

    Short ... Hope this helps =)

Re: Setting environment variables
by cat2014 (Monk) on Feb 10, 2001 at 04:57 UTC
    this is the way i've always done it in my scripts, when i didn't want to change the environment variable outside of the program:

    { local %ENV{NAME_OF_VARIABLE}="new-value"; #do whatever you want with the new environment in here }

    you should make sure that you don't stomp on global environment variables by always changing the variable with local. if you're really sure that you want to do that, check out the node above. but i think that normally want to think twice about changing environment variables when the user doesn't expect it. -- cat