SPUG: better way?

charles.e.derykus at boeing.com charles.e.derykus at boeing.com
Tue Aug 10 15:34:11 CDT 1999


> Better way to get just the domain from referer?
> I think this code will show my newbieness (but it works...)
> <HACK>
>  my $re = referer();
>  my $doubleslash = rindex($re,'//');
>  my $headslash = substr($re,$doubleslash+2);
>  my $domslash = index($headslash,'/');
>  print substr($headslash,0,$domslash);
> </HACK>

Another possibility is to make URI::URL take care of that
stuff, e.g. 

use URI::URL;

my $url = URI::URL->new('http://www.amazon.com');
my($scheme, $user, $pass , $host, $port) = $url->crack;


hope this helps,
--
Charles DeRykus

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list