Net::Whois::Norid - Lookup WHOIS data from norid.


Net-Whois-Norid documentation Contained in the Net-Whois-Norid distribution.

Index


Code Index:

NAME

Top

Net::Whois::Norid - Lookup WHOIS data from norid.

SYNOPSIS

Top

  my $whois = Net::Whois::Norid->new('thefeed.no');
  print $whois->post_address;
  print $whois->organization->fax_number;

DESCRIPTION

Top

This module provides an object oriented API for use with the Norid whois service. It uses Net::Whois::Raw internally to fetch information from Norid.

METHODS

new

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

lookup

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

get

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 Net::Whois::Norid object. The method is a case insensitive.

AUTOLOAD

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

SEE ALSO

Top

Net::Whois::Raw http://www.norid.no

CAVEATS

Top

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

AUTHOR

Top

Marcus Ramberg mramberg@cpan.org

LICENSE

Top

This module is distributed under the same terms as Perl itself.

1;


Net-Whois-Norid documentation Contained in the Net-Whois-Norid distribution.

package Net::Whois::Norid;

use Net::Whois::Raw;
use strict;

our $VERSION='0.04';
use vars qw/$AUTOLOAD/;

sub AUTOLOAD {
    my $self=shift;
    $AUTOLOAD =~ s/.*:://;
    return $self->get($AUTOLOAD);
}

sub new {
  my ($proto,$lookup)=@_;
  my $class=ref $proto||$proto;
  my $self=bless {},$class;
  return $self unless $lookup;
  $self->lookup($lookup);
  return $self;
}

sub get {
    my ($self,$key) = @_;
    $key=lc($key);
    if (exists $self->{"${key}_handle"} ) {
        my @objs=(map { $self->new($_) }
                split (m/\n/,$self->{"${key}_handle"}));
        return ( wantarray ? @objs : $objs[0] );
    }
    return $self->{$key};
}

sub lookup {
  my ($self,$lookup) = @_;
  return $self->_parse(whois($lookup,'whois.norid.no'));
}

sub _parse {
    my ($self,$whois)=@_;
    foreach my $line (split("\n",$whois)) {
        if (my ($key,$value) = $line =~ m/^(\w+[^.]+)\.{2,}\:\s*(.+)$/) {
            # replace spaces and - with _ for accessors.
            $key =~ y/ -/_/;
            $key = lc($key);
            $self->{$key} = 
                ($self->{$key} ? $self->{$key}."\n$value" : $value);
      }
  }
}