line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::IANA::TLD; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
70022
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
601
|
use LWP::Simple; |
|
1
|
|
|
|
|
71875
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::IANA::TLD - IANA TLDs database |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.01 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
IANA TLDs database |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Net::IANA::TLD; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# for each new(), the latest TLD data will be downloaded from IANA's website |
29
|
|
|
|
|
|
|
# you should cache the object |
30
|
|
|
|
|
|
|
my $tld = Net::IANA::TLD->new(); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
print $tld->version, "\n"; |
33
|
|
|
|
|
|
|
print $tld->date, "\n"; |
34
|
|
|
|
|
|
|
print $tld->size, "\n"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# validate if a given TLD exists |
37
|
|
|
|
|
|
|
my $given_tld = "com"; |
38
|
|
|
|
|
|
|
print "The TLD $given_tld exists\n" if $tld->has_tld($given_tld); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# dump all tlds |
42
|
|
|
|
|
|
|
use Data::Dumper; |
43
|
|
|
|
|
|
|
my $hash_ref = $tld->tlds; |
44
|
|
|
|
|
|
|
print Dumper $hash_ref; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
50
|
|
|
|
|
|
|
my $tld = Net::IANA::TLD->new(); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new { |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
57
|
0
|
|
|
|
|
|
my $iana_data = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"; |
58
|
0
|
|
0
|
|
|
|
my $res = get($iana_data) || die "can't fetch $iana_data"; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my %hash; |
61
|
0
|
|
|
|
|
|
my $version = ""; |
62
|
0
|
|
|
|
|
|
my $date = ""; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my @res = split/\n/,$res; |
65
|
0
|
|
|
|
|
|
my $copyright = shift @res; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ($copyright =~ /Version (\d+), Last Updated (.*)$/) { |
68
|
0
|
|
|
|
|
|
$version = $1; |
69
|
0
|
|
|
|
|
|
$date = $2; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $size = scalar @res; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for (@res) { |
75
|
0
|
0
|
|
|
|
|
next if /^#/; |
76
|
0
|
|
|
|
|
|
$hash{$_}=1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
bless {version=>$version, date=>$date, size=>$size, tlds=>\%hash}, $class; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 verison |
84
|
|
|
|
|
|
|
$tld->version; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub version { |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
$self->{'version'}; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 date |
96
|
|
|
|
|
|
|
$tld->date; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub date { |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
$self->{'date'}; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 size |
108
|
|
|
|
|
|
|
$tld->size; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub size { |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
$self->{'size'}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 tlds |
121
|
|
|
|
|
|
|
# fetch all tlds |
122
|
|
|
|
|
|
|
my $hash_ref = $tld->tlds; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub tlds { |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
129
|
0
|
|
|
|
|
|
$self->{'tlds'}; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 has_tld |
134
|
|
|
|
|
|
|
# return undef if given tld not exists |
135
|
|
|
|
|
|
|
my $res = $tld->has_tld($given_tld); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub has_tld { |
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my $key = shift; |
142
|
0
|
|
|
|
|
|
$key = uc($key); |
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
return exists($self->{tlds}->{$key}) ? 1 : undef; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Wesley Peng, C<< >> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 BUGS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
155
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
156
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SUPPORT |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
perldoc Net::IANA::TLD |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
You can also look for information at: |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * CPAN Ratings |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
L |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * Search CPAN |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Wesley Peng. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This is free software, licensed under: |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; # End of Net::IANA::TLD |