maxmind / GeoIP2-perl

Perl API for MaxMind's GeoIP2 web services and databases
https://metacpan.org/release/GeoIP2/
Other
18 stars 11 forks source link

Returning country subdivision #49

Closed waghanza closed 7 years ago

waghanza commented 7 years ago

Hello,

Is there a way to get the country subdision (https://en.wikipedia.org/wiki/ISO_3166-2) from GeoLite2-Country.mmdb ?

For example :

Regards,

oschwald commented 7 years ago

Yes, you can access it at $record->most_specific_subdivision->iso_code. There may be more than one level of subdivisions for a location; if you want something other than the most specific, use ->subdivisions instead. The value is only the second half of the ISO 3166-2 code, i.e., after the -. If you want the 3166-1 prefix, you will have to get that from $record->country->iso_code.