Net-Whois
view release on metacpan or search on metacpan
# local /$ rather than undef /$
# Thanks to Chris Nandor for pointing this out
#
# Revision 1.3 1999/08/08 22:53:54 dhudes
# change \r and \n in network connection to \x0d\x0a for portability
#
# Revision 1.2 1999/07/25 03:01:04 dhudes
# 1. Fix to address changes by Network Solutions in response to WHOIS requests
# (strip out leading disclaimer)
# 2. fix record created and record created internal tags
# 3. Reformat POD portion
#
# Revision 1.1 1999/07/20 03:54:11 dhudes
# Initial revision
#
package Net::Whois;
require 5.004;
use strict;
use Carp;
=head1 NAME
Net::Whois - Get and parse "whois" domain data from InterNIC
=head1 SYNOPSIS
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" }
@{$w->servers};
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 ;
=head1 DESCRIPTION
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.
=head1 AUTHOR
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.
=head1 COPYRIGHT
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.
=cut
use IO::Socket;
use IO::File;
use Carp;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = '1.9';
require Exporter;
@ISA = qw(Exporter);
@EXPORT = ();
my $server_name = 'whois.internic.net';
my $server_addr;
my %TLDs = ( COM => 'whois.networksolutions.com', NET => 'whois.networksolutions.com', EDU => 'whois.networksolutions.com', ORG => 'whois.networksolutions.com', ARPA =>'whois.arin.net', MIL =>'whois.nic.mil');
my %US_State = (
AL => 'ALABAMA',
AK => 'ALASKA',
AZ => 'ARIZONA',
( run in 2.824 seconds using v1.01-cache-2.11-cpan-0d23b851a93 )