in reply to Changing a unix users environment

I posted a snippet a while back that is probably what you're looking for. Just put it at the top of your perl script and reference the 'set_normal' shell script you mentioned above and give it a try.