Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Getting the URL of a referer

by ACJavascript (Acolyte)
on Dec 23, 2003 at 16:49 UTC ( [id://316652]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all,

I SEEK THE WISDOM OF THE PERL MONKS! hehe

Okay I need to know this:
Say the referer is http://www.yahoo.com/s=2342&stuff=asdfsd

I read the referer using ENV{'HTTP_REFERER'} - NOW
How can I split it up so that All I have like is www.yahoo.com?

Im pretty sure its going somthing to do with substr but I can't figure it out. Please any help would be most appreciated!
A*C

Replies are listed 'Best First'.
Re: Getting the URL of a referer
by chromatic (Archbishop) on Dec 23, 2003 at 18:13 UTC

    Alternately, use the URI module and the host() method.

Re: Getting the URL of a referer
by Thelonius (Priest) on Dec 23, 2003 at 18:18 UTC
    First, this "http://www.yahoo.com/s=2342&stuff=asdfsd" is a URL; this "www.yahoo.com" is a domain name or host name. Second, be aware that the referer is not always present.

    There are many ways to do this (say, maybe that should be a slogan :-).

    The best way, if you have the URI module installed, is this:

    use URI::URL; my $host = URI::URL->new($ENV{'HTTP_REFERER'})->host;
    That will handle more obscure cases, such as "https://joe@www.yahoo.com:4040/fred?billy".
      There are many ways to do this (say, maybe that should be a slogan :-).

      Sorry man, you're a little too late for that. We've already got the slogan for that. Yours is so close I can't help but wonder if you already know it and the smiley emoticon is hinting at the slogan. Here t'is:

      TIMTOWTDI: There Is More Than One Way To Do It

        Thanks alot guys/gals I will try all of your suggestions!!!

        A*C
Re: Getting the URL of a referer
by barrd (Canon) on Dec 23, 2003 at 17:37 UTC
    Rather than "do it for you", have a look at this link... then you'll be able to do it yourself.

    Much more satisfying that way. ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2025-06-22 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.