in reply to Re: Environment Variable Setting
in thread Environment Variable Setting

this is only true within csh correct? I can't simply

source sge_sigma.csh;

Does perl have a "source" command?

system("source sge_sigma.csh");

doesn't work

Thanks!

Replies are listed 'Best First'.
Re^3: Environment Variable Setting
by aaron_baugher (Curate) on Apr 23, 2012 at 21:14 UTC

    If you're in a csh shell (or most other shells), then yes, entering source sge_sigma.csh at the command line will cause the contents of that file to be interpreted and take effect in the current shell.

    bannor:~/work/perl/monks$ csh bannor:~/work/perl/monks> cat test.csh setenv MYTEST "This is a test." bannor:~/work/perl/monks> echo $MYTEST MYTEST: Undefined variable. bannor:~/work/perl/monks> source test.csh bannor:~/work/perl/monks> echo $MYTEST This is a test.

    You can't do this from within a Perl script, because it's a sub-process of the shell, so it can't change its parent's environment. To put it another way, you can change environment variables within a Perl script by use of the %ENV hash, and those will be inherited by any child processes that your Perl script spawns, but they can't go "upstream" to the parent process.

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.