Scroll to navigation

Number::Phone::NANP(3pm) User Contributed Perl Documentation Number::Phone::NANP(3pm)

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.

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

This module should not be used directly. It will be loaded as necessary by Number::Phone:

    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

METHODS

The following methods from Number::Phone are overridden:

The constructor, you should never have to call this yourself. To create an object the canonical incantation is "Number::Phone-"new('+1 ...')>.
For some countries operator data is available.
Returns a string telling where and when the data for operators was last updated, looking something like:

    "localcallingguide.com at Wed Sep 30 10:37:39 2020 UTC"
    

The current value of this is also documented in Number::Phone::Data.

The number is valid within the numbering scheme. It may or may not yet be allocated, or it may be reserved.
NANP-globals like 1-800 aren't geographic, the rest are.
NANP-globals like 1-800 aren't mobile. For most others we just don't know because the data isn't published. libphonenumber has data for *some* countries, so we use that if we can.
NANP-globals are fixed lines, for the rest we generally don't know with some exceptions as per is_mobile above.
The number is a '555' number. Numbers with the D, E, and F digits set to 555 are not allocated to real customers, and are intended for use in fiction. eg 212 555 2368 for Ghostbusters.

NB, despite Ghostbusters above, only 555-0100 to 555-0199 are actually reserved.

Area code 710 is reserved for the US Feds, but apparently only one number in the whole area code works.
The number is free to the caller. 800, 844, 855, 866, 877 and 888 "area codes"
The number is charged at a higher rate than normal. The 900 "area code" and some parts of 242 and 246 (Bahamas and Barbados).
The number is a "personal" number. The 500, 533, 544, 566 and 577 "area codes".
Returns 1.
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.

BUGS/FEEDBACK

Please report bugs at <https://github.com/DrHyde/perl-modules-Number-Phone/issues>, 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

2022-06-03 perl v5.34.0