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
In reply to Re: Set shell environment variables from within a perl script
by Corion
in thread Set shell environment variables from within a perl script
by reluctant_techie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |