Telephony::CountryDialingCodes 1.02 review
DownloadTelephony::CountryDialingCodes is a Perl module that can convert international dialing codes to country codes and vice versa. SYNO
|
|
Telephony::CountryDialingCodes is a Perl module that can 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.
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.
Requirements:
Perl
Telephony::CountryDialingCodes 1.02 search tags