Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have an html file that makes requests to a perl script. Is there a way for the perl script to know which html file is calling it without passing any data to the perl script. Is there a way in perl to know the referal page? Thanks

Replies are listed 'Best First'.
Re: Referal Page
by btrott (Parson) on May 06, 2000 at 07:56 UTC
    This is a CGI script, yes?

    Check the HTTP_REFERER environment variable. Yes, it's mis-spelled, but we make do. :)

    If you're using mod_perl, use

    $r->header_in('Referer')
    where $r is an Apache::Request object.

    Keep in mind that the refer(r)er variable isn't always set extremely reliably by browsers.

      The bottom line is, use HTTP_REFERER for "gee, that's nice to know" sorts of information but not for "everything breaks if this is wrong."
RE: Referal Page
by Anonymous Monk on May 06, 2000 at 18:42 UTC
    $variable = $ENV{HTTP_REFERER}; gets the page from which the cgi program called.