Telephony-CountryDialingCodes reviews

cpanratings
 

RSS | Module Info | Add a review of Telephony-CountryDialingCodes

Telephony-CountryDialingCodes (1.02) ****

I was hacking the PABX today, to generate real-time statistics on
international calls being made. Sadly, someone is abusing the
system, and now we have to try and catch them. After a bit of coding,
I was able to pull out international calls that looked like
00417929nnn.

As I don't have the international dialling codes memorised off by
heart, I figured there would be a module on CPAN to do it for me.
Sure enough, a search for "dialing codes" returned this module as
the first hit.

It installed without a hitch, but I had to write a bit of make-work
code to get it to do what I wanted. First off, it will only isolate
dialing prefixes from numbers if the number starts with + (plus).
My numbers started with 00.

So I had to munge the number a bit:

$dialer->extract_dialing_code(

do { my $n = $number; $n =~ s/^00/+/; $n}
);

Fair enough, now I had the dialling prefix (41) extracted. I then
had to take this prefix and call another method to get the list of
ISO countries back, so the code wound up looking like this:

my @iso = $dialer->country_codes(

$dialer->extract_dialing_code(

do { my $n = $number; $n =~ s/^00/+/; $n}

)
);

Now I have my ISO codes, all I have to do is use Net::Domain::TLD
or Geography::Countries and I'm home.

But it would have been nice to avoid jumping through all those hoops
and go straight from number to ISO list. Possibly specifying in the
new() constructor that international numbers start with '00' (instead
of the default '+'). I might send a patch to do this in my copious
spare time *snort*.

41 is CH, or Switzerland, in case you were wondering.