root@sugzum:~/host# cat b2.pl #!/usr/bin/perl use feature qw(say); use Mozilla::PublicSuffix qw(public_suffix); open F, "<host.txt" or die $!; while (<F>) { $hostname = "$_"; } close F; 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"; root@sugzum:~/ssh2smtp# cat host.txt 200-206-30-98.customer.tdatabrasil.net.br root@sugzum:~/ssh2smtp# perl b2.pl Invalid TLD found in '200-206-30-98.customer.tdatabrasil.net.br ' at b2.pl line 9.
Sorry, I'm a beginner. I can't figure it out to understand how this works.
In reply to Re^4: Module to get domain name from hostname
by gatkins
in thread Module to get domain name from hostname
by gatkins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |