in reply to Keeping environment variables after perl has exited
Just a thought as I know little or nothing about unix but would having your program set the environment vars and then exec the appropriate shell give you the result you are after?