From
perldoc perlfaq8:
Code: Select all
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 vis-
ible?
Unix
In the strictest sense, it can't be done--the script executes as a different
process from the shell it was started from. Changes to a process are not
reflected in its parent--only in any children created after the change.
There is shell magic that may allow you to fake it by eval()ing the script's
output in your shell; check out the comp.unix.questions FAQ for details.
I think they mean printing stuff to STDOUT from your Perl script that your shell will eval itself, i.e. running your Perl script like this (using bash):
Code: Select all
chester ~ $ cat script.pl
print qq|export TEST=yep|;
chester ~ $ echo $TEST
chester ~ $ eval `perl script.pl`
chester ~ $ echo $TEST
yep
See also
http://www.faqs.org/faqs/unix-faq/faq/part2/ perhaps. (Part 2 has stuff about environment variables.)