The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Number::Phone::NANP - NANP-specific methods for Number::Phone

DESCRIPTION

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.

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.

SYNOPSIS

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';

METHODS

The following methods from Number::Phone are overridden:

is_valid

The number is valid within the numbering scheme. It may or may not yet be allocated, or it may be reserved.

country_code

Returns 1.

country

Returns the two-letter ISO country code for this number.

regulator

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.

areacode

Return the area code for the number.

areaname

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".

subscriber

Return the subscriber part of the number.

format

Return a sanely formatted version of the number, complete with IDD code.

BUGS/FEEDBACK

Please report bugs by email, including, if possible, a test case.

I welcome feedback from users.

LICENCE

You may use, modify and distribute this software under the same terms as perl itself.

AUTHOR

David Cantrell <david@cantrell.org.uk>

Copyright 2012