in reply to Set shell environment variables from within a perl script
It's not clear to me which environment you want to affect.
If you want to affect the environment of your process or your child processes, just use the %ENV hash:
$ENV{CVSROOT}='<cvs>';
If you want to affect the environment of your parent process, you can't. At least not without cooperation of the parent process. The standard process is to emit a shell script and have the parent process execute that shell script:
#!/usr/bin/perl -w print 'export CVSROOT=<cvs>';
... and call that script from the shell (script) as:
`myscript.pl`
eval `myscript.pl`
system has no effect because it creates a child process, which dutifully changes its environment and then exits. And at process exit, all changes to the environment of that process are lost.
Update: Fixed shell code as per moritz++ reply
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Set shell environment variables from within a perl script
by moritz (Cardinal) on May 05, 2008 at 17:07 UTC |