0 #!/usr/bin/perl 1 use strict; 2 my @SUFFIX = qw(com net org); 3 # feed list of words you want to check for 4 while (<>) { 5 chomp; 6 for my $suffix (@SUFFIX) { 7 my $name = "$_.$suffix"; 8 my $status = do_lookup($name); 9 print "$name: $status\n"; 10 } 11 } 12 sub do_lookup { 13 my $name = shift; 14 # try the DNS first (faster) 15 my $dns = `nslookup -type=NS $name 2>/dev/null`; 16 return "used by $1" if $dns =~ /nameserver = (\S+)$/m; 17 # try whois 18 my $whois = `whois $name`; 19 return "registered to $1" if $whois =~ /Name Server:\s+(\S+)/; 20 # otherwise not found 21 return 'available'; 22 }