NAME
InternetData::Result - what an address lookup answers
SYNOPSIS
my $result = $client->lookup('146.70.116.130');
$result->ip; # '146.70.116.130'
$result->is_anycast; # 0
$result->location->{country}; # the ISO 3166 country code
$result->asn->{name}; # who runs the announcing network
$result->company->{name}; # who holds the address
$result->is_hosting; # 1, 0, or undef when your plan omits it
$result->is_hosting // 0; # read an absent field as false
$result->has('is_hosting'); # 1 if your plan carries it at all
ABSENT IS NOT FALSE
An absent field is one your plan does not include. It never means "we checked and found nothing", so undef and 0 are genuinely different answers.
This is the one place Perl makes it easy to get wrong, because undef, 0, '' and a missing hash key are all false:
if ($result->is_hosting) { ... } # WRONG: absent and false look alike
if (($result->is_hosting // 0)) { ... } # right: absent reads as false
if ($result->has('is_hosting')) { ... } # right: asks whether it was served
// (defined-or) is the reader for "treat absent as false", and has is the reader for "was this served at all". A result is also a plain hash reference, so exists $result->{is_hosting} is has spelled out and defined $result->{is_hosting} is the same test one level down.
A paid member inside a shared object is absent the same way, so ask with exists: exists $result->location->{city}.
A detail object that is present but empty ({}, and [] for web) means the flag above it is false. A populated one always carries every one of its keys.
METHODS
ip, is_bogon
Always present. is_bogon is set for reserved space, which the client answers itself without a request.
is_tor, is_relay, is_anycast, is_carrier, is_satellite, is_ssh, is_smtp, is_web, is_dns_resolver, is_bittorrent
On every answer, with a key or without one: 1 or 0.
is_vpn, is_resproxy, is_dcproxy, is_mobproxy, is_pubproxy, is_hosting, is_cdn
The paid flags: 1, 0, or undef when your plan omits the field.
vpn, tor, relay, resproxy, dcproxy, mobproxy, pubproxy, hosting, cdn, carrier, satellite, ssh, smtp, web, dns_resolver, bittorrent
The detail behind each flag, as plain hash references (web an array reference of the web servers found), or undef when your plan omits them. Unlimited answers tor and relay; every paid plan answers them all.
location, asn, company, hostname, abuse
On every answer, with a key or without one. location, asn, company and abuse are plain hash references whose paid members are absent on Unlimited: location carries the country there and the city, coordinates and the rest on a paid plan, asn its country and rpki_status, company its type and country, and abuse everything past email. hostname is the reverse-DNS name, an empty string where there is none.
whois, rwhois, hosted_domains
Paid: the WHOIS and RWHOIS records for the range, and how many domains point at the address, or undef when your plan omits them.
trial_expired
On answers to a key on the free plan only: 0 while its organization's daily trial lasts (every field for the first 100 lookups each UTC day), 1 once the answer has Unlimited's, and undef on any other answer.
has($field)
Whether your plan carries $field. Croaks on a name that is not a field.
fields
The field names this answer carried, in wire order.
raw
The decoded response body, untouched. Treat it, and the result itself, as read only: the cache hands the same object to every later caller of an address.