GeoIP2...ivision(3pm)

πŸ“¦
version 2.006002 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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>

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