Jason
have you tried checking the ENV hash?
if there is a referrer and it has been set by the user agent and is passed through to the web server then $ENV{HTTP_REFERER} will have that value in your script.
be aware that there are often cases where the request is referred but the referrer is not specified in the request.