in reply to can't get $ENV{HTTP_REFERER}

If you used Cgi.pm you would have that nice referer method on the $request object.

Ofcourse the Referer HTTP header is not obligatory for the browser to set, and even in some circumstances it is should not be set:

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

from rfc2616.