If someone simply typed the scripts URL into their browser, there would be no referer. Otherwise, from my experience, it should work. I'm positive that after submitting a form to a script, the script's http_referer variable would give the URL to the form. Try creating an HTML document that links to the script, clicking on the link, and seeing what happens.

As for 'Document_URL', if you are trying to get the URL of the script, use $ENV{'SCRIPT_NAME'}