NAME
Telephony::CountryDialingCodes - international dialing code to country code conversion class.
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.
You can call these methods as class methods or you can create an object and call these methods as object methods. The difference is that if you call them in object context that the internal lookup tables are free'd when the object is destroyed, otherwise if you call the methods in class context, then the internal lookup tables are global and will persist for the lifespan of the current process. It's not really a big deal which approach you choose, so for the sake of style, use the object method approach if you have no clue which is better.
PUBLIC CLASS METHODS
new
Constructor.
Parameters: none
Returns: object
PRIVATE CLASS METHODS
_init_lookup_tables
Loads the data into internal lookup tables if necessary.
Parameters: none
Returns: void
PUBLIC CLASS OR OBJECT METHODS
country_codes
Returns the ISO-3166 alpha2 country code(s) for the given dialing code
Parameters: unsigned int, international dialing access code
Returns: array of country codes
dialing_code
Returns the international dialing code for the given ISO-3166 alpha2 country code, or undef if no match could be found.
Parameters: ISO-3166 alpha2 country code
Returns: unsigned int or undef
extract_dialing_code
Extracts the international dialing code from the given international telephone number.
Parameters: international telephone number, for example '+521234567890'.
Returns: string or undef
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
SEE ALSO
Geography::Countries for ISO-3166 alpha2 country codes and names.
COPYRIGHT
Copyright (C) 2004 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 (google your ass off for my email address thanks to spam)