GeoIP2...ivision(3pm)
π GeoIP2::Record::Subdivision β the perl 3pm manual, bestie edition π
okay so. this is GeoIP2::Record::Subdivision, a Perl module, and yes it's a 3pm page (that's the section for Perl modules, iykyk). buckle up, it's short but it's cute.
β¨ NAME β¨
GeoIP2::Record::Subdivision</purl> β it holds all the data for the subdivision record that's tied to an IP address. that's it, that's the job π«Ά
πΈ VERSION πΈ
version 2.006002 β she's specific, she's numbered, she's iconic.
π¦ SYNOPSIS π¦
here's the whole vibe in code form, no cap:
use 5.008;
use GeoIP2::WebService::Client;
my $client = GeoIP2::WebService::Client->new(
account_id => 42,
license_key => 'abcdef123456',
);
my $insights = $client->insights( ip => '24.24.24.24' );
my $subdivision_rec = $insights->most_specific_subdivision();
print $subdivision_rec->name(), "\n";
so you build a client, you ask about an IP, you pull the most specific subdivision, you print its name. slay. that's the whole flow π
π DESCRIPTION π
This class is where the subdivision-level data for an IP address lives. and what's a subdivision, you ask? it's a sub-country level administrative boundary β think province, think state, think "oh so that's why the flag emoji needs a second letter". π
heads up bestie: this record is returned by all the end points except the Country end point. so if you're only hitting Country, no subdivision for you, sorry. π
π METHODS π
This class provides the following methods β five of them, each one a little gem:
$subdivision_rec->confidence()
returns a value from 0-100 showing how confident MaxMind is that the subdivision is actually correct. it's giving "we're pretty sure but we're honest about it". β¨
important: this attribute is only available from the Insights end point and the GeoIP2 Enterprise database. nowhere else, bestie.
$subdivision_rec->geoname_id()
returns a geoname_id for the subdivision. that's the number that says "this place, yes, this one". π’
this attribute is returned by all end points except the Country end point.
$subdivision_rec->iso_code()
returns a string up to three characters long, containing the subdivision portion of the ISO 3166-2 code (<http://en.wikipedia.org/wiki/ISO_3166-2>). short, punchy, internationally agreed upon. π
this attribute is returned by all end points except the Country end point.
$subdivision_rec->name()
returns a name for the subdivision. the locale it gives you depends on the locales argument that was passed to the record's constructor β and that gets passed through from the GeoIP2::WebService::Client object you used to fetch the data that populated this record. so basically, whatever language you asked for up top is what you get here. π
if the record doesn't have a name in any of the locales you asked for, this method returns undef. yes. undef. she said "no thoughts, no name". π
this attribute is returned by all end points except the Country end point.
$subdivision_rec->names()
returns a hash reference where the keys are locale codes and the values are names. it's the whole roster, not just the one you picked. π
wanna know which locale codes are even possible? go look at GeoIP2::WebService::Client, it's got the list.
this attribute is returned by all end points except the Country end point.
π«Ά SUPPORT π«Ά
found a bug? first of all, relatable. second of all, submit it through <https://github.com/maxmind/GeoIP2-perl/issues>. that's the spot. π
π AUTHORS π
these are the legends who made this happen, show some respect:
- Dave Rolsky <drolsky@maxmind.com>
- Greg Oschwald <goschwald@maxmind.com>
- Mark Fowler <mfowler@maxmind.com>
- Olaf Alders <oalders@maxmind.com>
β COPYRIGHT AND LICENSE β
This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. fr fr, go wild, it's free. π
and that's the page!! written for perl v5.36.0, dated 2022-11-21, and yeah the header/footer said GeoIP2...ivision(3pm) because manpage headers love to truncate things dramatically. anyway. ily, go look up some subdivisions. bye bestie!! π¦πΈπ
π¦ where this page comes from
- debian bookworm: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms