Something like this should work...
my $domain = 'www.station.fire.org';
if ($domain =~ /([^\.]+\.[^\.]+)$/) {
print "$1\n";
}
else {
print "Failed to find domain\n";
}
This is very lenient in the matching, so it should match all valid domain
names as well as a lot of invalid ones. If there is the possibility of
invalid domain names (ie. "this is not a domain.name") you will need
something stronger.
Rob
-----Original Message-----
From: perl [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 02, 2003 12:54 PM
To: [EMAIL PROTECTED]
Subject: base domain parsing www.mydomain.com
Please help me parse this www.mydomain.com to just mydomain.com
Below are some scenarios in which all I want is the last two values,
mydomain.com :
mydomain.com = mydomain.com
www.yourdomain.com = yourdomain.com
www.station.fire.org = fire.org
results in just the base domain.
thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]