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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
package Net::Domain::TLD;
=head1 NAME
Net::Domain::TLD - Gives ability to retrieve currently available tld
names/descriptions and perform verification of given tld name
=head1 SYNOPSIS
use Net::Domain::TLD;
my $domain_list = Net::Domain::TLD->new;
my @ccTLDs = $domain_list->ccTLDs;
=head1 DESCRIPTION
The purpose of this module is to provide user
with current list of available top level domain names
including new ICANN additions and ccTLDs
=head1 COPYRIGHT
Copyright (c) 2003 Alexander Pavlovic. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
=cut
use strict;
use warnings;
use Memoize;
use constant NEW_TLDS => '_newTLDs';
use constant GENERIC_TLDS_OPEN => '_gTLDs_open';
use constant GENERIC_TLDS_RESTRICTED => '_gTLDs_restricted';
use constant CC_TLDS => '_ccTLDs';
sub BEGIN {
our ($VERSION) = '$Revision: 1.5 $' =~ /Revision: ([\d.]+)/;
}
use constant TLD_PROFILE => {
#fetched from http://www.icann.org/tlds/
&NEW_TLDS => {
q{aero} => q{Air-transport industry},
q{biz} => q{Businesses},
q{coop} => q{Cooperatives},
q{info} => q{Unrestricted use},
q{museum} => q{Museums},
q{name} => q{For registration by individuals},
q{pro} => q{Accountants, lawyers, and physicians},
},
#fetched from http://www.dnso.org/constituency/gtld/gtld.html
#specific defininitions from http://whatis.techtarget.com
&GENERIC_TLDS_OPEN => {
q{com} => q{Commercial organization},
q{net} => q{Network connection services provider},
q{org} => q{Non-profit organizations and industry standard groups}
},
&GENERIC_TLDS_RESTRICTED => {
q{gov} => q{United States Government},
q{mil} => q{United States Military},
q{edu} => q{Educational institution},
q{int} => q{International treaties/databases}
},
#fetched from http://www.iana.org/cctld/cctld-whois.htm
&CC_TLDS => {
q{ac} => q{Ascension Island},
q{ad} => q{Andorra},
q{ae} => q{United Arab Emirates},
q{af} => q{Afghanistan},
q{ag} => q{Antigua and Barbuda},
q{ai} => q{Anguilla},
q{al} => q{Albania},
q{am} => q{Armenia},
q{an} => q{Netherlands Antilles},
q{ao} => q{Angola},
q{aq} => q{Antartica},
q{ar} => q{Argentina},
q{as} => q{American Samoa},
q{at} => q{Austria},
q{au} => q{Australia},
q{aw} => q{Aruba},
q{az} => q{Azerbaijan},
q{ba} => q{Bosnia and Herzegovina},
q{bb} => q{Barbados},
q{bd} => q{Bangladesh},
q{be} => q{Belgium},
q{bf} => q{Burkina Faso},
q{bg} => q{Bulgaria},
q{bh} => q{Bahrain},
q{bi} => q{Burundi},
q{bj} => q{Benin},
q{bm} => q{Bermuda},
q{bn} => q{Brunei Darussalam},
q{bo} => q{Bolivia},
q{br} => q{Brazil},
q{bs} => q{Bahamas},
q{bt} => q{Bhutan},
q{bv} => q{Bouvet Island},
q{bw} => q{Botswana},
q{by} => q{Belarus},
q{bz} => q{Belize},
q{ca} => q{Canada},
q{cc} => q{Cocos (Keeling) Islands},
q{cd} => q{Congo, Democratic Republic of the},
q{cf} => q{Central African Republic},
q{cg} => q{Congo, Republic of},
q{ch} => q{Switzerland},
q{ci} => q{Cote d'Ivoire},
q{ck} => q{Cook Islands},
q{cl} => q{Chile},
q{cm} => q{Cameroon},
q{cn} => q{China},
q{co} => q{Colombia},
q{cr} => q{Costa Rica},
q{cu} => q{Cuba},
q{cv} => q{Cap Verde},
q{cx} => q{Christmas Island},
q{cy} => q{Cyprus},
q{cz} => q{Czech Republic},
q{de} => q{Germany},
q{dj} => q{Djibouti},
q{dk} => q{Denmark},
q{dm} => q{Dominica},
q{do} => q{Dominican Republic},
q{dz} => q{Algeria},
q{ec} => q{Ecuador},
q{ee} => q{Estonia},
q{eg} => q{Egypt},
q{eh} => q{Western Sahara},
q{er} => q{Eritrea},
q{es} => q{Spain},
q{et} => q{Ethiopia},
q{fi} => q{Finland},
q{fj} => q{Fiji},
q{fk} => q{Falkland Islands (Malvina)},
q{fm} => q{Micronesia, Federal State of},
q{fo} => q{Faroe Islands},
q{fr} => q{France},
q{ga} => q{Gabon},
q{gd} => q{Grenada},
q{ge} => q{Georgia},
q{gf} => q{French Guiana},
q{gg} => q{Guernsey},
q{gh} => q{Ghana},
q{gi} => q{Gibraltar},
q{gl} => q{Greenland},
q{gm} => q{Gambia},
q{gn} => q{Guinea},
q{gp} => q{Guadeloupe},
q{gq} => q{Equatorial Guinea},
q{gr} => q{Greece},
q{gs} => q{South Georgia and the South Sandwich Islands},
q{gt} => q{Guatemala},
q{gu} => q{Guam},
q{gw} => q{Guinea-Bissau},
q{gy} => q{Guyana},
q{hk} => q{Hong Kong},
q{hm} => q{Heard and McDonald Islands},
q{hn} => q{Honduras},
q{hr} => q{Croatia/Hrvatska},
q{ht} => q{Haiti},
q{hu} => q{Hungary},
q{id} => q{Indonesia},
q{ie} => q{Ireland},
q{il} => q{Israel},
q{im} => q{Isle of Man},
q{in} => q{India},
q{io} => q{British Indian Ocean Territory},
q{iq} => q{Iraq},
q{ir} => q{Iran (Islamic Republic of)},
q{is} => q{Iceland},
q{it} => q{Italy},
q{je} => q{Jersey},
q{jm} => q{Jamaica},
q{jo} => q{Jordan},
q{jp} => q{Japan},
q{ke} => q{Kenya},
q{kg} => q{Kyrgyzstan},
q{kh} => q{Cambodia},
q{ki} => q{Kiribati},
q{km} => q{Comoros},
q{kn} => q{Saint Kitts and Nevis},
q{kp} => q{Korea, Democratic People's Republic},
q{kr} => q{Korea, Republic of},
q{kw} => q{Kuwait},
q{ky} => q{Cayman Islands},
q{kz} => q{Kazakhstan},
q{la} => q{Lao People's Democratic Republic},
q{lb} => q{Lebanon},
q{lc} => q{Saint Lucia},
q{li} => q{Liechtenstein},
q{lk} => q{Sri Lanka},
q{lr} => q{Liberia},
q{ls} => q{Lesotho},
q{lt} => q{Lithuania},
q{lu} => q{Luxembourg},
q{lv} => q{Latvia},
q{ly} => q{Libyan Arab Jamahiriya},
q{ma} => q{Morocco},
q{mc} => q{Monaco},
q{md} => q{Moldova, Republic of},
q{mg} => q{Madagascar},
q{mh} => q{Marshall Islands},
q{mk} => q{Macedonia, Former Yugoslav Republic},
q{ml} => q{Mali},
q{mm} => q{Myanmar},
q{mn} => q{Mongolia},
q{mo} => q{Macau},
q{mp} => q{Northern Mariana Islands},
q{mq} => q{Martinique},
q{mr} => q{Mauritania},
q{ms} => q{Montserrat},
q{mt} => q{Malta},
q{mu} => q{Mauritius},
q{mv} => q{Maldives},
q{mw} => q{Malawi},
q{mx} => q{Mexico},
q{my} => q{Malaysia},
q{mz} => q{Mozambique},
q{na} => q{Namibia},
q{nc} => q{New Caledonia},
q{ne} => q{Niger},
q{nf} => q{Norfolk Island},
q{ng} => q{Nigeria},
q{ni} => q{Nicaragua},
q{nl} => q{Netherlands},
q{no} => q{Norway},
q{np} => q{Nepal},
q{nr} => q{Nauru},
q{nu} => q{Niue},
q{nz} => q{New Zealand},
q{om} => q{Oman},
q{pa} => q{Panama},
q{pe} => q{Peru},
q{pf} => q{French Polynesia},
q{pg} => q{Papua New Guinea},
q{ph} => q{Philippines},
q{pk} => q{Pakistan},
q{pl} => q{Poland},
q{pm} => q{St. Pierre and Miquelon},
q{pn} => q{Pitcairn Island},
q{pr} => q{Puerto Rico},
q{ps} => q{Palestinian Territories},
q{pt} => q{Portugal},
q{pw} => q{Palau},
q{py} => q{Paraguay},
q{qa} => q{Qatar},
q{re} => q{Reunion Island},
q{ro} => q{Romania},
q{ru} => q{Russian Federation},
q{rw} => q{Rwanda},
q{sa} => q{Saudi Arabia},
q{sb} => q{Solomon Islands},
q{sc} => q{Seychelles},
q{sd} => q{Sudan},
q{se} => q{Sweden},
q{sg} => q{Singapore},
q{sh} => q{St. Helena},
q{si} => q{Slovenia},
q{sj} => q{Svalbard and Jan Mayen Islands},
q{sk} => q{Slovak Republic},
q{sl} => q{Sierra Leone},
q{sm} => q{San Marino},
q{sn} => q{Senegal},
q{so} => q{Somalia},
q{sr} => q{Suriname},
q{st} => q{Sao Tome and Principe},
q{sv} => q{El Salvador},
q{sy} => q{Syrian Arab Republic},
q{sz} => q{Swaziland},
q{tc} => q{Turks and Caicos Islands},
q{td} => q{Chad},
q{tf} => q{French Southern Territories},
q{tg} => q{Togo},
q{th} => q{Thailand},
q{tj} => q{Tajikistan},
q{tk} => q{Tokelau},
q{tm} => q{Turkmenistan},
q{tn} => q{Tunisia},
q{to} => q{Tonga},
q{tp} => q{East Timor},
q{tr} => q{Turkey},
q{tt} => q{Trinidad and Tobago},
q{tv} => q{Tuvalu},
q{tw} => q{Taiwan},
q{tz} => q{Tanzania},
q{ua} => q{Ukraine},
q{ug} => q{Uganda},
q{uk} => q{United Kingdom},
q{um} => q{US Minor Outlying Islands},
q{us} => q{United States},
q{uy} => q{Uruguay},
q{uz} => q{Uzbekistan},
q{va} => q{Holy See (City Vatican State)},
q{vc} => q{Saint Vincent and the Grenadines},
q{ve} => q{Venezuela},
q{vg} => q{Virgin Islands (British)},
q{vi} => q{Virgin Islands (USA)},
q{vn} => q{Vietnam},
q{vu} => q{Vanuatu},
q{wf} => q{Wallis and Futuna Islands},
q{ws} => q{Western Samoa},
q{ye} => q{Yemen},
q{yt} => q{Mayotte},
q{yu} => q{Yugoslavia},
q{za} => q{South Africa},
q{zm} => q{Zambia},
q{zw} => q{Zimbabwe}
}
};
=head1 PUBLIC INTERFACES
=over 4
=item new
Creates new Net::Domain::TLD instance
my $tld = Net::Domain::TLD->new;
=cut
sub new {
for ( qw ( All TLDs_new gTLDs_open gTLDs_restricted ccTLDs exists ) ) {
memoize $_;
}
return bless {}, shift;
}
=item All
my @list = $tld->All;
returns list or hash ref of all TLDs names/descriptions
=cut
sub All {
my %list;
for ( NEW_TLDS, GENERIC_TLDS_OPEN, GENERIC_TLDS_RESTRICTED, CC_TLDS ) {
@list{keys %{TLD_PROFILE->{$_}}} = values %{TLD_PROFILE->{$_}};
}
return wantarray ? keys %list : \%list;
}
=item TLDs_new
my @list = $tld->TLDs_new;
returns list or hash ref of new TLD names/descriptions
=cut
sub TLDs_new {
wantarray ? keys % { TLD_PROFILE->{&NEW_TLDS} } : TLD_PROFILE->{&NEW_TLDS};
}
=item gTLDs_open
my $names = $tld->gTLDs_open;
returns a list or hash ref of generic TLD names/descriptions available to general public
=cut
sub gTLDs_open {
wantarray ? keys % { TLD_PROFILE->{&GENERIC_TLDS_OPEN} } : TLD_PROFILE->{&GENERIC_TLDS_OPEN};
}
=item gTLDs_restricted
my @list = $tld->gTLDs_restricted;
returns a list or hash ref of generic TLD names/descriptions restricted for assignment to specific users
=cut
sub gTLDs_restricted {
wantarray ? keys % { TLD_PROFILE->{&GENERIC_TLDS_RESTRICTED} } : TLD_PROFILE->{&GENERIC_TLDS_RESTRICTED};
}
=item ccTLDs
my $names = $tld->ccTLDs;
returns a list or hash ref of country code TLD names/descriptions
=cut
sub ccTLDs {
my $self = shift;
wantarray ? keys % { TLD_PROFILE->{&CC_TLDS} } : TLD_PROFILE->{&CC_TLDS};
}
=item exists
determines if given tld exists, returns 1 if tld is valid and 0 if not
$tld->exists(q{info}) ? print q{ok} : print q{not ok};
=cut
sub exists {
my ( $self, $tld ) = @_;
$tld = lc $tld;
$tld =~ s/\s+//g;
my $list = $self->All;
return exists $list->{$tld};
}
1;
=back
=head1 AUTHOR
Alexander Pavlovic <alex-1@telus.net>
=cut
|