NAME

Geo::Location::IP::Record::Subdivision - Subdivision details

VERSION

version 0.002

SYNOPSIS

use Geo::Location::IP::Database::Reader;
my $reader = Geo::Location::IP::Database::Reader->new(
  file => '/path/to/City.mmdb',
);
eval {
  my $city_model   = $reader->city(ip => '1.2.3.4');
  my @subdivisions = $city_model->subdivisions;
};

DESCRIPTION

This class contains details about a subdivision associated with an IP address.

All fields may be undefined.

An IP address may be associated with multiple subdivisions such as federal states, counties and provinces.

SUBROUTINES/METHODS

new

my $subdivision = Geo::Location::IP::Record::Subdivision->new(
  names => {
    en => 'Westminster',
  },
  geoname_id => 3333218,
  iso_code   => 'WSM',
  locales    => ['en'],
);

Creates a new subdivision record.

confidence

my $confidence = $subdivision->confidence;

Returns a value in the range from 0 to 100 that indicates the confidence that the subdivision is correct.

geoname_id

my $geoname_id = $subdivision->geoname_id;

Returns the subdivision's GeoNames identifier as a number.

iso_code

my $iso_code = $subdivision->iso_code;

Returns the region part of the subdivision's ISO 3166-2 code.

name

my $name = $subdivision->name;

Returns the subdivision's name in the chosen language.

names

my %names = %{$subdivision->names};

Returns a hash reference that maps locale codes to localized names.

DIAGNOSTICS

None.

CONFIGURATION AND ENVIRONMENT

None.

DEPENDENCIES

None.

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.