The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Telephony::CountryDialingCodes - convert international dialing codes to country codes and vice versa.

SYNOPSIS

# Usage method 1 (using object methods):
use Telephony::CountryDialingCodes;
my $o = new Telephony::CountryDialingCodes();
my $country_code = 'NL';
print "The dialing access code for country $country_code is " . $o->dialing_code($country_code) . "\n";
my $dialing_code = 1;
my @country_codes = $o->country_codes($dialing_code);
print "The country code(s) for dialing access code $dialing_code is/are: " . join(',',@country_codes) . "\n";


# Usage method 2 (using class methods):
use Telephony::CountryDialingCodes;
my $country_code = 'NL';
print "The dialing access code for country $country_code is " . Telephony::CountryDialingCodes->dialing_code($country_code) . "\n";
my $dialing_code = 1;
my @country_codes = Telephony::CountryDialingCodes->country_codes($dialing_code);
print "The country code(s) for dialing access code $dialing_code is/are: " . join(',',@country_codes) . "\n";

# Extracting an int'l dialing code from an int'l phone number:
use Telephony::CountryDialingCodes;
my $o = new Telephony::CountryDialingCodes();
my $dialing_code = $o->extract_dialing_code('+521234567890');
# $dialing_code will contain 52.

DESCRIPTION

This class exports a method for determining a country's international dialing code, and another method for doing the reverse: i.e. determining the country code(s) that belong(s) to a given international dialing code.

PUBLIC METHODS

All the methods below can be called in either object or class context.

new()

The constructor.

country_codes($)

Returns an array of ISO-3166 alpha2 country codes associated with the given international dialing code.

dialing_code($)

Returns the international dialing code for the given ISO-3166 alpha2 country code, or undef if no match is found.

extract_dialing_code($)

Extracts the international dialing code from the given international telephone number which can be passed in one of the following formats:

- with leading +, e.g. '+521234567890'
- w/o leading +, e.g. '521234567890'
- with leading zero's, e.g. '00521234567890' (not recommended).

REFERENCES

[1]

TheFreeDictionary.com List of country calling codes http://encyclopedia.thefreedictionary.com/list%20of%20country%20calling%20codes. 2004-11-16

[2]

Country / Internet Code / Dialing Code http://www.loglink.com/countrystats.asp?mode=cs17. 2004-11-18

[3]

List of country calling codes http://en.wikipedia.org/wiki/List_of_country_calling_codes. 2007-02-23

SEE ALSO

Geography::Countries for ISO-3166 alpha2 country codes and names.

Locale::Country for ISO-3166 alpha2 country codes and names.

Number::Phone::Country for looking up country codes from telephone numbers.

COPYRIGHT

Copyright (C) 2004-2009 Craig Manley. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

AUTHOR

Craig Manley