in reply to Exporting variables from perl script to shell
Aristotle touched on it, but I thought I would reinforce his point. In most [all?] Unix-like operating systems, it's not possible for a process to modify its parent's environment. When you execute a program from most shells, it is executed in a child process. Thus, a shell script cannot add environment variables to the interactive shell when run as ./shell-script. Nor can any other program. That's just how it is.
Now, you might be thinking "then how do environment variables in my config files get loaded?!?" The answer is that those files are not executed in a child process. They are sourced. That is, the file is read in and executed directly in the current process. This can only work with a script written for the shell that's sourcing it, so this technique will not work for a Perl script.
|
|---|