Number::Phone and friends
Perl Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
build-data.stubs teach NANP about is_{tollfree,specialrate,personal} Oct 19, 2016


This distribution contains several modules.

To install them modules, do the usual dance:

    perl Makefile.PL
    make test
    make install

Number::Phone is a base class for parsing and dealing with phone numbers.

Number::Phone::UK inherits methods from it, over-riding some with UK-
specific implementations.  The intention is that other people will write
other country-specific classes exposing the same API.

Number::Phone::Country is a useful module which is used by the NANP modules.
It was originally written by T. J. Mather but is now maintained by me.

Number::Phone::StubCountry::* are automatically generated from Google's
libphonenumber project's data.  They do not support all the features of
Number::Phone, but will support many use-cases and should "fail
gracefully" if you try to use unsupported features.

Number::Phone::NANP implements functionality common to all NANP countries.
There is a subclass of this for each such country.  The only significant
difference between this and libphonenumber is that libphonenumber
erroneously reports that 800 numbers and other non-geographic numbers are
in the US.

Please note that the build-data.* files are not intended for your use.
I use them to re-build the database of UK number allocations.  If you
choose to use them, on your own head be it!

The data used in these modules have come from all sorts of places.  Most
of them disclaim any responsibility for errors in the data.  I disclaim
all responsibility for errors too, even if my code makes your PBX turn

Data sources used include: - treat this with caution, it seems to be no
    longer maintained
  various telcos and regulatory bodies linked from the above: - for UK data - for US data - for Canadian data
  Google's libphonenumber:
    whose data are used for NANP area code names and for "stub"

You can find the most recent version of the source code on Github at:

There is an online demo of some of its functionality here:

And you can browse the online documentation here:

The most important bits of doco to read are Number::Phone,
Number::Phone::Country, Number::Phone::UK, and
Number::Phone::NANP.  Most other stuff is either a subclass of one
of those that provides country-specific data, or is a "helper"
module that supplies data in a non-user-oriented format, intended
only for internal use.