#! /usr/bin/perl -w #-------------------------------------------------------------------------- # Check registration of domain names #-------------------------------------------------------------------------- use strict; use File::Basename; use Getopt::Long; # Normal TLD that anybody can use use constant NORMAL => 'N'; # Restricted TLD reserved for certain types of organizations use constant RESTRICTED => 'R'; # Government TLD that are impossible to acquire, and also seemingly # difficult to even whois query use constant IMPOSSIBLE => 'I'; my @tld; while () { my ($status, $tld, $desc) = /(\S*)\s*(\S*)\s*(.*)/; push @tld, { tld => $tld, status => $status, desc => $desc }; } my @normalTld = map {$_->{status} eq NORMAL ? $_->{tld} : ()} @tld; my @specialTld = map {$_->{status} eq RESTRICTED ? $_->{tld} : ()} @tld; my ($prefix, @domains, %opts); my $basename = basename $0; my $usage = < VER GetOptions(\%opts, '--all', '--full', '--list', '--tlds=s', '--help|H', '--version|V', ) or die "$usage\n"; die "$usage\n" if $opts{help}; die "$version\n" if $opts{version}; if ($opts{list}) { print <{status}, $_->{tld}, $_->{desc} for (@tld); print "\nMore information can be found here: "; print "http://en.wikipedia.org/wiki/TLD\n"; exit; } $prefix = shift; die "Must supply a prefix or domain\n\n$usage\n" unless $prefix; if ($opts{full}) { push @domains, $prefix; } elsif ($opts{tlds}) { my @tld = split /,/, $opts{tlds}; @domains = map { $prefix . "." . $_ } @tld; } else { my @tld = @normalTld; push @tld, @specialTld if $opts{all}; @domains = map { $prefix . $_ } @tld; } for my $domain (@domains) { printf "%2sregistered: %s\n", ((`whois "$domain"` =~ /Domain Name:/) ? "" : "UN"), $domain; } __DATA__ R .aero air-transport industry R .arpa address and routing parameter area N .biz business N .com commercial R .coop cooperatives I .edu educational I .gov United States government N .info information R .int international organizations I .mil United States military R .museum museums N .name individuals, by name N .net network N .org organization R .pro professions R .travel travel and travel agency related N .us United States of America