The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Net::DLookup - Perform domain lookups on 2-letter and 3-letter TLDs


     use Net::DLookup;

     # Initialize Net::DLookup object
     my $dlu = Net::DLookup -> new;

     # Replace domain definitions from a file
     $dlu -> LoadTLD($file, 1);

     # Add domain definitions from a file
     $dlu -> LoadTLD($file, 0);

     # Check domain name validity and assign it to the object
     @errors = $dlu -> IsValid($domain);

     # Return availability
     @response = $dlu -> DoWhois(0);

     # Return availability and registrar information
     @response = $dlu -> DoWhois(1);


Net::DLookup performs domain lookups for 2-letter and 3-letter top level domains. It also verifies the validity of domain names by checking punctuation, length, metacharacters, etc..

Information for currently recognized top level domains is included within the module. This list may be replaced or added to by calling $dlu->LoadTLD().

With the advent of new registrars for 3-letter top level domains, it's become difficult to get the whois output from a single domain lookup, unless you know what registration agency to look at. Net::DLookup solves this problem by checking Internic's database first and then performing a second query to the respective registrar for full whois output.


These functions must be used in order:

Of course:

     use Net::DLookup;

Create an object that contains the default top level domains.

     my $dlu = Net::DLookup -> new;

Validate domain name ($domaintocheck) and associate it with the object. This must be the full domain name, such as

     my @errors = $dlu -> IsValid($domaintocheck);

It checks for the following possible errors:

Is 67 characters or less for 3-letter TLDs
Is not a 3rd level domain for 3-letter TLDs (
Is 26 characters or less for 2-letter TLDs
Is not a 4th level domain for 2-letter TLDs (
Does not start or end with a non-alphanumeric character
Does not contain non alphanumeric characters (except a dash) within the domain name
Is a valid TLD*

* All CCTLDs (Country Code TLDs) currently listed at IANA as well as the .com, .net, .org, .edu and .mil are checked

@errors will contain a list of all possible errors that the domain name may have, such as:

Domain name can't start or end with non-alphanumeric character.
Domains with the .com extension cannot exceed 67 characters.

Last, the domain lookup.

     @response = $domain->Net::DLookup::DoWhois();
Is domain registered? 1 for yes; 0 for no
Name of Registration Agency or Country
URL of Registration Agency for TLD
Whois Server for TLD
Whois Output
A "worded" reponse for domain availability "{domain} is available"

If you're looking up a 3-letter TLD domain (.com, .net, .org, .edu and .mil), you have the choice to NOT perform the second lookup. This would be useful if you're just checking for domain availability and don't care who's already registered it. You can disable the second lookup by removing the 1. This will give you Internic's plain Jane, uninformative whois information.

     @response = $domain->Net::DLookup::DoWhois(1);


Net::DLookup requires that the Sockets (included with the Perl distribution) module is installed.


Net::DLookup Version 1.01 6/10/2000


Registration agencies are finicky beasts. They may change their whois server, urls, or responses (that this module relies on) without notice. As of 6/10/2000, the agency data in the module is accurate.


Many thanks goes to Michael Chase for the new LoadTLD() and DumpTLD() routines.


D. Jasmine Merced <>, CPAN ID: DJASMINE

The Perl Archive <>


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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 97:

=over should be: '=over' or '=over positive_number'