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:
if( $ENV{'SHELL'} =~ m:/bash$: ) { printf 'export ENVAR=%s\n', $value; ... } elsif ( $ENV{'SHELL'} =~ m:/csh$: ) ...
In reply to Re: How to execute commands in the same shell as Perl script
by chrestomanci
in thread How to execute commands in the same shell as Perl script
by bhagperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |