Number...e::NANP(3pm)
π Number::Phone::NANP β the NANP bestie manual π
okay so this is Number...e::NANP(3pm), from the User Contributed Perl Documentation collection, and it's genuinely iconic. let's get into it π«Ά
πΈ NAME πΈ
Number::Phone::NANP β literally all the NANP-specific methods for Number::Phone. that's it, that's the name π
β¨ DESCRIPTION β¨
so basically this is a base class, and what it does is encapsulate all that info about phone numbers in the North American Numbering Plan (NANP) that's common to every NANP country β aka the ones whose international dialling code is +1. one big happy +1 family fr fr.
Country-specific modules should inherit from this module and provide their own versions of methods as necessary. but bestie, listen β they should NOT provide an is_valid method or a constructor. that's the rule. lowkey non-negotiable. π
π¦ SYNOPSIS π¦
this module should not be used directly. like, do not come for it personally. it gets 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
see how it just happens? main character energy. it shows up when it's needed and never before π β¨
π METHODS π
the following methods from Number::Phone are overridden:
newβ the constructor, and bestie you should never have to call this yourself. to create an object the canonical incantation (yes, incantation, it's giving spellwork π§) is `Number::Phone->new('+1 ...')>.operatorβ for some countries operator data is available. that's it, that's the whole vibe.data_sourceβ returns a string telling you 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. receipts available, iykyk π
is_validβ the number is valid within the numbering scheme. but ngl, it may or may not yet be allocated, or it may be reserved. valid β yours, bestie.is_geographicβ NANP-globals like1-800aren't geographic, the rest are.
as a special case, 1-600 is non-geographic. so too will be 1-622/633/644/655/677/688 when they come in to service. they're not here yet but they're on the way π
is_mobileβ NANP-globals like1-800aren't mobile. for most others we just don't know because the data isn't published π.libphonenumberhas data for some countries, so we use that if we can. slay for the ones we can help.is_fixed_lineβ NANP-globals are fixed lines, for the rest we generally don't know, with some exceptions as peris_mobileabove. same energy, different method.is_dramaβ the number is a'555'number. numbers with theD,E, andFdigits set to555are not allocated to real customers, and are intended for use in fiction. eg212 555 2368for Ghostbusters. yes that one, iconic cinema moment π¬
NB, despite Ghostbusters above, only555-0100to555-0199are actually reserved. so don't get too excited. π
is_governmentβ area code710is reserved for the US Feds, but apparently only one number in the whole area code works. one. single. number. π government efficiency fr.is_tollfreeβ the number is free to the caller.800,833,844,855,866,877and888"area codes". free is free bestie πis_specialrateβ the number is charged at a higher rate than normal. the900"area code" and some parts of242and246(Bahamas and Barbados). check your wallet before you dial πΈis_personalβ the number is a"personal"number. the500,533,544,566and577"area codes".country_codeβ returns1.regulatorβ returns informational text relevant to the whole NANP. note that when this method is inherited by a subclass it returnsundef, meaning"not known", but returns information about the NANPA when called on an object of classNumber::Phone::NANP. context is everything, periodt.areacodeβ return the area code for the number.areanameβ return the name for the area code, if applicable, otherwise returnsundef. for instance, for a number beginning with+1 201 200it would return"Jersey City, NJ". cute little location reveal β¨subscriberβ return the subscriber part of the number.formatβ return a sanely formatted version of the number, complete with IDD code. a little glow-up for your digits π
π BUGS/FEEDBACK π
please report bugs at <https://github.com/DrHyde/perl-modules-Number-Phone/issues>, including, if possible, a test case. test cases are the love language of maintainers, no cap.
I welcome feedback from users. π«Ά genuinely! tell them things!
π LICENCE π
you may use, modify and distribute this software under the same terms as perl itself. generous king behaviour, we love to see it π
π AUTHOR π
David Cantrell <david@cantrell.org.uk>
Copyright 2026
and that's the whole page bestie, you ate it up πΈ β written up from perl v5.40.1, dated 2026-06-11, and it lives in the User Contributed Perl Documentation section of the manual, where all the good stuff hangs out. mwah π
π¦ where this page comes from
- ubuntu stonking: libnumber-phone-perl 4.0011-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms