File: get_root_domain

package info (click to toggle)
libdomain-publicsuffix-perl 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 536 kB
  • sloc: perl: 14,272; makefile: 2
file content (96 lines) | stat: -rwxr-xr-x 2,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl
use strict;
use warnings;
use Domain::PublicSuffix;

my $domain_name = shift(@ARGV);
usage('Requires a domain name to continue.') unless ( $domain_name );

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

printf( "%12s: %s\n", 'Domain', $domain_name );
my $root_domain = $suffix->get_root_domain($domain_name);

if ( $suffix->error ) {
    printf( "%12s: %s\n", 'Error',       $suffix->error );
}
printf( "%12s: %s\n", 'Root Domain', $root_domain ) if ($root_domain);
printf( "%12s: %s\n", 'Suffix',      $suffix->suffix ) if ($suffix->suffix);
printf( "%12s: %s\n", 'TLD',         $suffix->tld ) if ($suffix->tld);


sub usage {
	my ( $error ) = @_;
	
	print "get_root_domain - Domain::PublicSuffix " . ($Domain::PublicSuffix::VERSION or 'dev') . "\n";
	print "Usage: get_root_domain <domainname>\n";
	
	exit(1);
}

1;

__END__

=head1 NAME

get_root_domain - Retrieve suffix info from a domain using Domain::PublicSuffix

=head1 DESCRIPTION

The get_root_domain utility uses Domain::PublicSuffix to get the root or
suffix for a fully qualified domain name. Given a FQDN, this utility will output
the "root domain", and the suffix and TLD used to calculate that root domain.

=over

=item * Public Info Site: 

L<http://publicsuffix.org/>

=back

=head1 SYNOPSIS

get_root_domain <domainname>

=head1 EXAMPLE USAGE

=over

$ get_root_domain www.google.com
      Domain: www.google.com
 Root Domain: google.com
      Suffix: com
         TLD: com

$ get_root_domain www.google.co.uk
      Domain: www.google.co.uk
 Root Domain: google.co.uk
      Suffix: co.uk
         TLD: uk


=back

=head1 RETURN VALUES

Returns 0 if a successful lookup is done, non-zero otherwise.

=head1 SEE ALSO

Domain::PublicSuffix(3pm)

=head1 BUGS

Please report any bugs or feature requests to C<bug-domain-publicsuffix at rt.cpan.org>,
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Domain-PublicSuffix>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut