Thanks for the information. There is one thing I should mention in case you are unaware of this; I've tested the sub and it works fine except for certain things. In our .profile we have a variable called TWO_TASK and it's set to isw_live, getenv ignores this line and doesn't set up the appropriate environmental variable. Things like PS1 & PS2 are also ignored. This may be intentional but as I can't find any documentation for env I thought I'd let you know. ( I also stuck in a couple of rogue variables fred=flintstone & barney=rubble and they were not picked up either.)
Cheers,Ronnie