|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: How to execute commands in the same shell as Perl scriptby chrestomanci (Curate) |
| on Sep 13, 2011 at 13:11 UTC ( #925696=note: print w/ replies, xml ) | Need Help?? |
|
I think bhagperl might be attempting to write a perl script that alters his environment similar to the very common bash idiom of sourcing a script such as: [username@localhost]$ . ./set_envs.shIf you attempt something like that with a perl script it does not work because perl runs in a child process of the current shell, and any changes it makes to it's environment don't affect the calling process (the user's shell). The solution (under unix) is to use eval and backticks and have perl emit the commands to change the environment to stdout. eg: [username@localhost]$ eval `perl set_envs.pl`Where the perl script is something like:
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||