in reply to ENV variables....

You should really use CGI.pm for that stuff. Do a Super Search for CGI and referal url and you should find all that you want to know and more.