Search notes:

Perl module Domain::PublicSuffix

#!/usr/bin/perl
use warnings;
use strict;

use Domain::PublicSuffix;

my $suffix = Domain::PublicSuffix->new() or die;

print_root('www.google.com');
print_root('foo.co.uk');
print_root('www.foo.bar.ch');
print_root('www.foo.co.uk');
print_root('www.foo.com.in');
print_root('www.foo.com.tr');
print_root('www.foo.com.br');
print_root('www.foo.com.cn');

sub print_root {
  my $host = shift;
  printf "%-15s -> %s\n", $host, $suffix->get_root_domain($host);
}

# Output:
# 
# www.google.com  -> google.com
# foo.co.uk       -> foo.co.uk
# www.foo.bar.ch  -> bar.ch
# www.foo.co.uk   -> foo.co.uk
# www.foo.com.in  -> com.in
# www.foo.com.tr  -> foo.com.tr
# www.foo.com.br  -> foo.com.br
# www.foo.com.cn  -> foo.com.cn
Github repository PerlModules, path: /Domain/PublicSuffix/script.pl

See also

Perl modules

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759407978, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Domain/PublicSuffix/index(69): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78