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";
In reply to Re^3: Module to get domain name from hostname
by Corion
in thread Module to get domain name from hostname
by gatkins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |