NOLookup::Whois::WhoisLookup - Lookup WHOIS data from Norid.


    use Encode;
    use NOLookup::Whois::WhoisLookup;
    # The $SERVER and $PORT can be set to what you need.
    # The defaults are the below, so in this case they don't
    # change anything.
    my $SERVER = '';
    my $PORT   = 43;

    # Example 1: Domain name lookup
    # Decode the query when needed, like for IDNs
    # or names with national characters.
    my $q = decode('UTF-8', '');

    my ($wh, $do, $ho) = NOLookup::Whois::WhoisLookup->new($q, $SERVER, $PORT);

    # $wh is always populated.
    # For a domain lookup, the $do and $ho objects should be 
    # used to access the domain and holder information.
    # In all other cases, $wh contains the information.
    if ($wh->errno) {
       print STDERR "Whois error: ", $wh->errno, "\n";
       if ($wh->raw_text) {
          print STDERR "Raw text   : ", $wh->raw_text, "\n";
    print $wh->post_address;
    print $wh->domain_name;
    print $wh->name;

    if ($do && $ho) {
       # when a domain name or domain handle is looked up,
       # $do contains the domain information,
       # and $ho contains the holder information
       print "Domain name   : ", encode('UTF-8', $do->domain_name), "\n";
       print "Holder name   : ", encode('UTF-8', $ho->name), "\n";
       print "Holder address: ", encode('UTF-8', $ho->post_address), "\n";

    # Example 2: Registrar lookup
    $q = 'reg2-norid';
    $wh = NOLookup::Whois::WhoisLookup->new($q);
    unless ($wh->errno) {
       print "Registrar name : ", encode('UTF-8', $wh->registrar_name), "\n";
       print "Registrar email: ", $wh->email_address, "\n";


This module provides an object oriented API for use with the Norid whois service. It uses the command line based whois interface internally to fetch information from Norid.

The values in the objects are decoded to internal perl data.

This code is stolen from Cpan package Net::Whois::Norid and adapted to suit our needs. Adaption was needed because create date etc. were not collected. We could've considered using the module as it was, but it also dragged in some more modules which seems a bit much for such a simple task.

Also nice to produce some more error codes.



The constructor. Takes an optional lookup argument. Returns a new object.


Do a whois lookup in the Norid database and populate the object from the result.


Use this to access any data parsed. Note that spaces and '-'s will be converted to underscores (_). For the special "Handle" entries, omitting the _Handle part will return a new NOLookup::Whois::WhoisLookup object.

The method is case insensitive.


Note: The name of this method is important, must be upper case and name must not be changed!

Provide a TO_JSON method for JSON usage, ref. TO_JSON discussion in

JSON does not handles objects, as the internals are not known, then we need a method to present the object as a hash structure for JSON to use. This method does the conversion from object to a hash ready for JSON encoding.


This module uses the autoload mechanism to provide accessors for any available data through the get mechanism above.


For now, support questions should be sent to:




Some rows in the whois data, like address lines, might appear more than once. In that case they are separated with line space. For objects, an array is returned.


Trond Haugen, <(nospam)info(at)>


Copyright (c) 2017 Trond Haugen <(nospam)info(at)>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.