Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

retrieving an URL

by Anonymous Monk
on Jul 05, 2000 at 01:57 UTC ( #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 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.
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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2023-03-21 02:14 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.