NAME

Net::Whois::Parser - module for parsing whois information

SYNOPSIS

use Net::Whois::Parser;

my $info = parse_whois( domain => $domain );
my $info = parse_whois( raw => $whois_raw_text, domain => $domain  );
my $info = parse_whois( raw => $whois_raw_text, server => $whois_server  );

$info = {
    nameservers => [
        { domain => 'ns.example.com', ip => '123.123.123.123' },
        { domain => 'ns.example.com' },
    ],
    emails => [ 'admin@example.com' ],
    domain => 'example.com',
    somefield1 => 'value',
    somefield2 => [ 'value', 'value2' ],
    ...
};

# Your own parsers

sub my_parser {
    my ( $text ) = @_;
    return {
        nameservers => [
            { domain => 'ns.example.com', ip => '123.123.123.123' },
            { domain => 'ns.example.com' },
        ],
        emails => [ 'admin@example.com' ],
        somefield => 'value',
        somefield2 => [ 'value', 'value2' ],
    };
}

$Net::Whois::Parser::PARSERS{'whois.example.com'} = \&my_parser;
$Net::Whois::Parser::PARSERS{'DEFAULT'}           = \&my_default_parser;

# If you want to get all values of fields from all whois answers
$Net::Whois::Parser::GET_ALL_VALUES = 1;
    # example
    # Net::Whois::Raw returns 2 answers
    $raw = [ { text => 'key: value1' }, { text => 'key: value2'}];
    $data = parse_whois(raw => $raw);
    # If flag is off parser returns
    # { key => 'value2' };
    # If flag is on parser returns
    # { key => [ 'value1', 'value2' ] };

# If you want to convert some field name to another:
$Net::Whois::Parser::FIELD_NAME_CONV{'Domain name'} = 'domain';

# If you want to format some fields.
# I think it is very useful for dates.
$Net::Whois::Parser::HOOKS{'expiration_date'} = [ \&format_date ];

DESCRIPTION

Net::Whois::Parser module provides Whois data parsing. You can add your own parsers for any whois server.

FUNCTIONS

parse_whois(%args)

Returns hash of whois data. Arguments:

'domain' - domain

'raw' - raw whois text

'server' - whois server

'which_whois' - option for Net::Whois::Raw::whois. Default value is QRY_ALL

CHANGES

See file "Changes" in the distribution

AUTHOR

Ivan Sokolov, <ivsokolov@cpan.org>

COPYRIGHT & LICENSE

Copyright 2009 Ivan Sokolov

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.