Net::Whois::RIPE::Object3pm
Ripe query results
Usage
use Net::Whois::RIPE::Object;$object = new Net::Whois::RIPE::Object;$object->debug(1);while ($line = $whois_socket->get()) {($attribute,$value) = ($line =~ /^(.+?):\s+(.+)$/);next unless $attribute;$object->add($attribute,$value);}$object->success || die;foreach $attribute ($object->attributes()) {foreach $value ($object->$attribute()) {printf "%s: %-s\n", $attribute, $value;}}print $object->content; # raw content from whois serverfor $error ($object->error) {...}for $warn ($object->warning) {...}
Overview
Encapsulates the results of a whois query. The attribute/value pairs of the response may then by accessed using the attribute as a method name.
These objects are created by Net::Whois::RIPE to be returned as query results.
Short background...a whois server would return the following for a person query.
person: Paul Gampeaddress: Level 1 - 33 Park Roadaddress: Milton, QLD, 4064country: AUphone: +61-7-3367-0490fax-no: +61-7-3367-0482e-mail: [email protected]nic-hdl: PG6-APremarks: APNIC Technical Operations Teammnt-by: MAINT-AP-APNIC-TECHchanged: [email protected] 19990909source: APNIC
Net::Whois::RIPE::Object parses the attribute's and values and add's them to itself. The RIPE object can then be used to access the attribute values using the attribute names as methods. A call to attributes returns an ordered list of all attributes parsed.
All values are stored as lists since some attributes are multiline (e.g. address). If there has been a problem with the query then the content method may provide output from the server that can be used to diagnose why.
$whois = Net::Whois::RIPE->new($host);$query = $whois->query('Paul Gampe');unless ($query->success) {print "There's been a problem...server response is...\n";print $query->content;exit}print "Paul's nic-hdl is ", $query->nic_hdl, "\n";
Attributes that had a dash '-' are converted to underscore '_' for method names.
Constructor
new(HANDLE)-
Creates a new RIPE object. Attempts to parse lines from HANDLE. Any parsing failure causes the constructor to return undef. Error messages are available via
errstr. HANDLE may be a file handle or a socket.
Methods
- content()
-
Returns the raw output from the whois server. In a list context it returns the lines from whois as a list. In a scalar context it returns the entire list in a scalar.
In the case where no ATTRIBUTE's are available via the
attributesmethod, then the content may hold information from whois as to why.
- attributes()
-
Returns the list of ATTRIBUTE's that were added by
add. The order of the list is the order the ATTRIBUTE's were added in.If no ATTRIBUTE's were added then an empty list is returned. Try calling
contentto obtain output from the whois server as to why.Call attributes to find out if the object was successfully parsed. success reports errors from the whois server. It is possible that success can report true but the object has no attributes.
- warning()
-
In a list context it returns an array of warning lines. In a scalar context it returns a \n separated string of warning lines.
These are the warnings from the whois server about the object.
- error()
-
In a list context it returns an array of error lines. In a scalar context it returns a \n separated string of error lines.
These are the errors from the whois server about the object.
success-
Returns 1 if no errors defined, 0 otherwise
debug(LEVEL)-
Sets/gets the debug level.
Caveats
Pod errors
Hey! The above document had some coding errors, which are explained below:
Around line 82:
|
'=item' outside of any '=over' |
|---|---|
Around line 88:
|
You forgot a '=back' before '=head1' |
Around line 90:
|
'=item' outside of any '=over' |
Around line 133:
|
You forgot a '=back' before '=head1' |
Releases
5 releases since Debian 4.0 (Etch); the text changed 2 times.