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?
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();
| [reply] [Watch: Dir/Any] [d/l] |
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}
| [reply] [Watch: Dir/Any] [d/l] |
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:
- It can be trivially faked
- It can be absent
- It can be wrong
So, beware the clueless attempting to give you clues.
-- Randal L. Schwartz, Perl hacker | [reply] [Watch: Dir/Any] [d/l] |
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
| [reply] [Watch: Dir/Any] |