in reply to Re^2: Module to get domain name from hostname
in thread Module to get domain name from hostname
If you have stripped away the TLD, the last non-dot characters are the domain name. Most likely, a regular expression is enough:
my $tld = public_suffix($hostname) or die "Invalid TLD found in '$hostname'"; $hostname =~ /([^.]+).\Q$tld\E$/ or die "Couldn't find domain name in '$hostname'"; my $domainname= $1; print "Domain name is $domainname.$tld\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Module to get domain name from hostname
by gatkins (Initiate) on Jan 29, 2015 at 16:10 UTC | |
|
Re^4: Module to get domain name from hostname
by gatkins (Initiate) on Jan 29, 2015 at 19:19 UTC | |
|
Re^4: Module to get domain name from hostname
by gatkins (Initiate) on Jan 29, 2015 at 19:12 UTC | |
by Corion (Patriarch) on Jan 30, 2015 at 07:52 UTC | |
by Anonymous Monk on Jan 30, 2015 at 14:07 UTC | |
|
Re^4: Module to get domain name from hostname
by gatkins (Initiate) on Jan 29, 2015 at 17:17 UTC | |
by Corion (Patriarch) on Jan 29, 2015 at 18:05 UTC |