Number::Phone::NANP - NANP-specific methods for Number::Phone
This is a base class which encapsulates that information about phone numbers in the North American Numbering Plan (NANP) which are common to all NANP countries - that is, those whose international dialling code is +1. If you are dealing with phone numbers in any of those countries, you should use this module. It will then load the country-specific modules for you as needed.
use
Country-specific modules should inherit from this module and provide their own versions of methods as necessary. However, they should not provide an is_valid method or a constructor.
is_valid
in a program:
use Number::Phone; my $phone_number = Number::Phone->new('+1 202 418 1440'); # $phone_number is now a Number::Phone::NANP::US my $other_phone_number = Number::Phone->new('+1 866 623 2282'); # $phone_number is non-geographic so is a Number::Phone::NANP
in a subclass:
package Number::Phone::NANP::CA; use base 'Number::Phone::NANP';
The following methods from Number::Phone are overridden:
The number is valid within the numbering scheme. It may or may not yet be allocated, or it may be reserved.
Returns 1.
Returns the two-letter ISO country code for this number.
Returns informational text relevant to the whole NANP. Note that when this method is inherited by a subclass it returns undef meaning "not known", but returns information about the NANPA when called on an object of class Number::Phone::NANP.
Return the area code for the number.
Return the name for the area code, if applicable, otherwise returns undef. For instance, for a number beginning with +1 201 200 it would return "Jersey City, NJ".
Return the subscriber part of the number.
Return a sanely formatted version of the number, complete with IDD code.
Please report bugs at https://github.com/DrHyde/perl-modules-Number-Phone/issues, including, if possible, a test case.
I welcome feedback from users.
You may use, modify and distribute this software under the same terms as perl itself.
David Cantrell <david@cantrell.org.uk>
Copyright 2012
To install Number::Phone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Number::Phone
CPAN shell
perl -MCPAN -e shell install Number::Phone
For more information on module installation, please visit the detailed CPAN module installation guide.