I saw plenty of solutions, but nobody really explained the problem in the example to you. There are two key rules to environment variables in Unix-like systems:
- Each process has its own environment, and each process can only modify its own environment.
- When one process creates a child process, the environment of the parent process is copied into the new environment for the child.
So, in your solution above, the profile script is executed in a child process. That is, the child gets copies of %ENV from your perl script (and the perl script got its %ENV from cron), proceeds to add/change the information as commanded in the script, and finally terminates. The changes to the child's environment go with it. Not a mark left on the world, poor kid. =)
mhoward - at - hattmoward.org