in reply to Setting env vars in current process

"Setting a value in %ENV changes the environment for both your process and child processes..."
This is true. Please be aware that the "current process" is your executing perl program itself. It is not the shell (or other program) that spawned your perl program.

So if your aim is to modify your shell environment - the parent process of your perl program - then you need a workaround.

There is a FAQ for this issue, although admittedly it's not very satisfactory:
I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.

  • Comment on Re: Setting env vars in current process

Replies are listed 'Best First'.
Re: Re: Setting env vars in current process
by ruscoekm (Monk) on Feb 11, 2003 at 19:31 UTC
    Nope, I only wanted to change the current process env. People seem pretty confident that you can do this. (So was I until just now!!) As discussed in reply above, I will just have to work out what else is wrong with my setting LD_LIBRARY_PATH for XML::LibXML. Cheers Kevin
      Perhaps you should have shown some code.
      If you're doing something like
      $ENV{'LD_LIBRARY_PATH'} = '/...'; use XML::LibXML;
      then the problem may be that the envar isn't getting set until after the library gets loaded. In which case, try
      BEGIN { $ENV{'LD_LIBRARY_PATH'} = '/...'; } use XML::LibXML;

      jdporter
      The 6th Rule of Perl Club is -- There is no Rule #6.

        No, that is not the issue. The problem is specific to the loader's caching of LD_LIBRARY_PATH. Replies above have links to solutions.