----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, April 19, 2006 5:04 PM
Subject: URL parsing
"foo.bar.com/ignore/this/".
Maybe this
$url = 'http://foo.bar.com/ignore/this/';
($protocol,$remainder,@domain_parts)=tear_it_up($url);
sub tear_it_up {
my $all = shift;
$all =~s#^(.+\.[a-zA-Z]+)(/)*(.*)$#$1#;
my $remain = $3;
my ($dom, $proto)=split('//:', reverse $all);
($dom,$proto)=(scalar reverse( $dom),scalar reverse( $proto));
my @parts = split(/\./, $dom);
return ($proto, $remain, @parts);
}
Now you have $protocol (eg. http, https, ftp), remainder ( "ignore/this/"
from your sample) and all parts of domain in @domain_parts like this:
url domain_parts
********************************************
www.foo.bar.com www foo bar com
foo.bar.com foo bar com
bar.com bar com
Can this help you?
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs