ProductOpener::GeoIP - finds the country name and iso code from the given IP address.
ProductOpener::GeoIP
is used to find the country name and iso code from the IP address using GeoIP2 API.
use ProductOpener::GeoIP qw/:all/; $geolite2_path = '/usr/local/share/GeoLite2-Country/GeoLite2-Country.mmdb'; $geolite2_path is a path to geo IP location max mind database file. Max Mind DataBase file(.mmdb) is a database format that maps the given IP addresses to their geolocation.
The module implements the functionality to find the country name, and iso code by using the GeoIP2 API. The functions used in this module take the IP address and return the geolocation.
get_country_for_ip()
takes the IP address as an input parameter and returns the country name where the IP address is located.
One scalar variable ip is passed as an argument.
If the function executes successfully it returns the country name. On the other hand, if it throws an exception, it simply returns undefined.
get_country_code_for_ip()
takes the IP address as input parameter and returns the country iso code where IP address is located.
One scalar variable ip is passed as an argument.
If the function executes successfully it returns the two-character ISO 3166-1 (http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country where the IP address is located (eg. "AF" for Afghanistan). On the other hand, if it throws an exception, it simply returns undefined.