Dana Hudes


Net::Whois - Get and parse "whois" domain data from InterNIC


Note that all fields except "name" and "tag" may be undef because "whois" information is erratically filled in.

use Net::Whois; use Carp;

 my $w = new Net::Whois::Domain $dom
 or die "Can't connect to Whois server\n;

 unless ($w->ok) { croak "No match for $dom";}

 print "Domain: ", $w->domain, "\n";
 print "Name: ", $w->name, "\n";
 print "Tag: ", $w->tag, "\n";
 print "Address:\n", map { "    $_\n" } $w->address;
 print "Country: ", $w->country, "\n";
 print "Name Servers:\n", map { "    $$_[0] ($$_[1])\n" }
 my ($c, $t);
 if ($c = $w->contacts) {
   print "Contacts:\n";
   for $t (sort keys %$c) {
     print "    $t:\n";
     print map { "\t$_\n" } @{$$c{$t}};
 print "Record created:", $w->record_created ;
 print "Record updated:", $w->record_updated ;


Net::Whois::Domain new() attempts to retrieve and parse the given domain's "whois" information from the InterNIC (whois.internic.net). If the server could not be contacted, is too busy, or otherwise does not process the query then the constructor does not return a reference and your object is undefined. If the constructor returns a reference, that reference can be used to access the various attributes of the domains' whois entry assuming that there was a match. The member function ok returns 1 if a match 0 if no match.

Note that the Locale::Country module (part of the Locale-Codes distribution) is used to recognize spelled-out country names; if that module is not present, only two-letter country abbreviations will be recognized.

The server consulted is "whois.internic.net". You can only get .org, .edu, .net, .com domains from Internic. Other whois servers for other Top-Level-Domains (TLD) return information in a different syntax and are not supported at this time. Also, only queries for domains are valid. Querying for a network will fail utterly since those are not kept in the whois.internic.net server (a future enhancement will add a network lookup function). Querying for NIC handles won't work since they have a different return syntax than a domain. Domains other than those listed won't work they're not in the server. A future enhancment planned will send the query to the appropriate server based on its TLD.


Originally written by Chip Salzenberg (chip@pobox.com) in April of 1997 for Idle Communications, Inc. In September of 1998 Dana Hudes (dhudes@hudes.org) found this but it was broken and he needed it so he fixed it. In August, 1999 Dana and Chip agreed to become co-maintainers of the module. Dana released a new version of Net::Whois to CPAN and resumed active development.


This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. If you make modifications, the author would like to know so that they can be incorporated into future releases.