NAME
Geo::Location::IP::Database::Reader - Read MaxMind DB files
VERSION
version 0.002
SYNOPSIS
use Geo::Location::IP::Database::Reader;
my $reader = Geo::Location::IP::Database::Reader->new(
file => '/path/to/City.mmdb',
locales => ['de', 'en'],
);
eval {
my $city_model = $reader->city(ip => '1.2.3.4');
my $city = $city_model->city;
my $country = $city_model->country;
printf "%s in %s\n", $city->name, $country->name;
};
DESCRIPTION
Read MaxMind DB files and map IP addresses to location information such as country and city names.
This is a Geo::Location::IP::Database::SimpleReader subclass that throws Geo::Location::IP::Error::Generic and Geo::Location::IP::Error::AddressNotFound exceptions on unsuccessful queries.
SUBROUTINES/METHODS
anonymous_ip
my $anon_ip_model = eval { $reader->anonymous_ip(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::AnonymousIP object. Dies on unsuccessful queries.
asn
my $asn_model = eval { $reader->asn(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::ASN object. Dies on unsuccessful queries.
city
my $city_model = eval { $reader->city(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::City object. Dies on unsuccessful queries.
connection_type
my $ct_model = eval { $reader->connection_type(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::ConnectionType object. Dies on unsuccessful queries.
country
my $country_model = eval { $reader->country(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::Country object. Dies on unsuccessful queries.
domain
my $domain_model = eval { $reader->domain(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::Domain object. Dies on unsuccessful queries.
enterprise
my $enterprise_model = eval { $reader->enterprise(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::Enterprise object. Dies on unsuccessful queries.
isp
my $isp_model = eval { $reader->isp(ip => '1.2.3.4') };
Takes an IP address as a string and returns a Geo::Location::IP::Model::ISP object. Dies on unsuccessful queries.
DIAGNOSTICS
- ->METHOD() method cannot be called with a TYPE database
-
A query method has been called on the wrong database type.
- Required param (ip) was missing
-
A query method has been called with an undefined value.
- me is not a valid IP
-
The string "me" cannot be passed as an IP address.
- The IP address you provided (IP) is not a public IP address
-
The specified IP address is private.
- No record found for IP address
-
No data is associated with the specified IP address.
See also IP::Geolocation::MMDB.
CONFIGURATION AND ENVIRONMENT
None.
DEPENDENCIES
See Geo::Location::IP::Database::SimpleReader.
INCOMPATIBILITIES
None.
BUGS AND LIMITATIONS
None known.
AUTHOR
Andreas Vögele <voegelas@cpan.org>
LICENSE AND COPYRIGHT
Copyright (C) 2025 Andreas Vögele
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.