http://www.perlmonks.org?node_id=966639


in reply to Environment Variable Setting

On unix, child processes inherit the environment from their parent, but any changes they make are not propagated back to the parent when the child quits.

Your csh script works because it runs in the same process as your shell, so changes made in it remain after the script exits.

The usual way to create a perl script that modifies the environment is to have it emit a shell script on stdout, and then eval the script's output. eg:

eval `perl set_my_env.pl`

The perl script just prints a series of setenv NAME value lines.