Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

retrieving an URL

by Anonymous Monk
on Jul 05, 2000 at 01:57 UTC ( [id://21061]=perlquestion: print w/replies, xml ) Need Help??

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

I'm a novice and really need some help. How would you grab the url from the html page that calls the cgi script?

Replies are listed 'Best First'.
Re: retrieving an URL
by Maclir (Curate) on Jul 05, 2000 at 04:09 UTC
    If you use the CGI.pm module, you will find that all of those "CGI environment variables" are made easy to access. For example:
    $calling_url = $q->referer();
Re: retrieving an URL
by lhoward (Vicar) on Jul 05, 2000 at 02:05 UTC
    The CGI specification dictates several environmental variables to be set. The complete list of all CGI environmental variables is located here. The variable you are interested in is HTTP_REFERER. In perl it is accessable as.
    $ENV{HTTP_REFERER}
RE: retrieving an URL
by merlyn (Sage) on Jul 07, 2000 at 13:16 UTC
    There's no reliable way to do it. Any answer that lists $ENV{HTTP_REFERER} or something derived from it needs a disclaimer that states:
    1. It can be trivially faked
    2. It can be absent
    3. It can be wrong
    So, beware the clueless attempting to give you clues.

    -- Randal L. Schwartz, Perl hacker

Re: retrieving an URL
by Chris2323 (Initiate) on Apr 14, 2001 at 20:28 UTC
    I am the one who betrayed the monastry and believes that modules are not good until you are an advanced monk! Try this without using modules: $referer = $ENV{'HTTP_REFERER'}; print $referer; The result will be the refering URL

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://21061]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found