Log in

View Full Version : Environment varibles after perl program ends


sfbattles
Apr 13, 2007, 06:52 AM
Is it possible to save the environment variable that Perl modified after the Perl program ends.
example
I want to use the PATH that my Perl script set as my unix PATH.



Can this be done?

asterisk_man
Apr 16, 2007, 07:37 PM
I don't claim to be a perl expert but I can't think of a way to do this. When perl closes it's environment and memory is discarded. If you had perl output the values you wish to use you could capture them and set them external to the perl script but this may be messy. For things like ksh or bash you would do this like:

. ScriptWhichSetsPath

But I am pretty sure this won't work for a perl script. ScriptWhichSetsPath is read line by line and executed in the current shell.

If you want to try to output the result and handle it in the script that called the perl code let me know and I can try to help you with that.