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 like 1-800 aren'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 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. 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 per is_mobile above. same energy, different method.
  • is_drama β€” 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. yes that one, iconic cinema moment 🎬
NB, despite Ghostbusters above, only 555-0100 to 555-0199 are actually reserved. so don't get too excited. πŸ’€
  • is_government β€” area code 710 is 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, 877 and 888 "area codes". free is free bestie πŸŽ€
  • is_specialrate β€” the number is charged at a higher rate than normal. the 900 "area code" and some parts of 242 and 246 (Bahamas and Barbados). check your wallet before you dial πŸ’Έ
  • is_personal β€” the number is a "personal" number. the 500, 533, 544, 566 and 577 "area codes".
  • country_code β€” returns 1.
  • 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. context is everything, periodt.
  • 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". 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