When trying to decode an object retured to you, Data::Dumper can be your best friend.

In this case,
use Net::Whois::IP qw(whoisip_query); use Data::Dumper; my $ip = "192.168.1.1"; my ($response,$array_of_responses) = whoisip_query($ip); print '$response is: ', Dumper( $response ); print '$array_of_responses is: ', Dumper( $array_of_responses) +;
reslt is:
$response is: $VAR1 = { 'OrgTechName' => 'Internet Corporation for Assigned Names an +d Number ', 'NameServer' => 'BLACKHOLE-2.IANA.ORG', 'Country' => 'US', 'PostalCode' => '90292-6695', 'OrgTechEmail' => 'res-ip@iana.org', 'RegDate' => '1994-03-15', 'NetHandle' => 'NET-192-168-0-0-1', 'NetName' => 'IANA-CBLK1', 'OrgTechPhone' => '+1-310-823-9358', 'City' => 'Marina del Rey', 'OrgName' => 'Internet Assigned Numbers Authority ', 'Comment' => ' ', 'Address' => '4676 Admiralty Way, Suite 330', 'OrgTechHandle' => 'IANA-ARIN', 'NetType' => 'IANA Special Use', 'CIDR' => '192.168.0.0/16 ', 'StateProv' => 'CA', 'Updated' => '2002-09-16', 'OrgID' => 'IANA', 'NetRange' => '192.168.0.0 - 192.168.255.255 ', 'Parent' => 'NET-192-0-0-0-0' }; $array_of_responses is: $VAR1 = undef;
The 'Var1 =' is just window-dressing added by Data::Dumper. The rest of the output looks like a hash, but is conatinined in {} rather than (), so it is a reference to hash. hence it is dereferenceed with ->. So to get the Tech contact's email, you'd say:
print "Tech contact's email is $response->{OrgTechEmail}\n";
Unfortunately, the keys in the hash erference are different depending on the registrar - using my IP address, I return a hashref where the Tech contact' email is accessed by:
print "Tech contact's email is $response->{TechEmail}\n";


--Bob Niederman, http://bob-n.com

In reply to Re: Help Dereferencing Net::Whois::IP by bobn
in thread Help Dereferencing Net::Whois::IP by Dru

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.