Number...one::UK(3pm)
πΈ NAME πΈ
okay so bestie, this is the man page β the header up top literally says Number...one::UK(3pm) because the terminal truncates it and frankly that's tragic π but whatever, it's the page for Number::Phone::UK, which is the UK-specific methods for Number::Phone. That's it, that's the whole vibe π
β¨ SYNOPSIS β¨
use Number::Phone;
$daves_phone = Number::Phone->new('+44 1234 567890');
ποΈ DATABASE ποΈ
okay so Number::Phone::UK uses a large database, and you get at it via Number::Phone::UK::Data. That database lives in a file, and normally only the little bits of it that you actually access will ever get loaded into memory. Cute, right? π
But here's the catch, bestie: it means creating Number::Phone::UK objects almost always involves disk access, so it's slow compared to data for some other countries. Literally slow. Not me crying about it π« There are two ways to dodge that slowness:
- First, if you don't need all the functionality you can use
Number::Phone::Lib. - Second, if you can accept slow startup β eg when your server starts β then you can call
Number::Phone::UK::Data->slurp()from your code, and that will pull the entire database into memory. It'll take a few minutes, and on a 64-bit machine it will consume of the order of 200MB of memory. Worth it for the speed tho π
The database uses Data::CompactReadonly. This may have some problems if you connect to it, fork(), and then try to access the database from multiple processes. We attempt to work around this by re-connecting to the database after forking. And it's, of course, not a problem at all if you slurp() the database before forking π
π METHODS π
The following methods from Number::Phone are overridden:
newβ the constructor. You should never have to call this yourself, bestie. To create an object the canonical incantation isNumber::Phone->new('+44 ...').data_sourceβ returns a string telling where and when the data that drives this class was last updated, looking something like:
"OFCOM at Wed Sep 30 10:37:39 2020 UTC"
The current value of this is also documented in Number::Phone::Data.
is_validβ the number is valid within the national numbering scheme. It may or may not yet be allocated, or it may be reserved. Any number which returns true for any of the following methods will also be valid. β¨is_allocatedβ the number has been allocated to a telco for use. It may or may not yet be in use, or may be reserved.is_dramaβ the number is intended for use in fiction π¬ OFCOM has allocated numerous small ranges for this purpose. These numbers will not be allocated to real customers. The authoritative source ishttp://stakeholders.ofcom.org.uk/telecoms/numbering/guidance-tele-no/numbers-for-drama.is_geographicβ the number refers to a geographic area.is_fixed_lineβ the number, when in use, can only refer to a fixed line.
(we can't tell whether a number is a fixed line, but we can tell that some are not.)
is_mobileβ the number, when in use, can only refer to a mobile phone π±is_pagerβ the number, when in use, can only refer to a pager. (iconic, honestly, who still has one)is_tollfreeβ callers will not be charged for calls to this number under normal circumstances π€is_specialrateβ the number, when in use, attracts special rates. For instance, national dialling at local rates, or premium rates for services.is_adultβ the number, when in use, goes to a service of an adult nature, such as porn πis_personalβ the number, when in use, goes to an individual person.is_corporateβ the number, when in use, goes to a business πΌis_ipphoneβ the number, when in use, is terminated using VoIP.is_network_serviceβ the number is some kind of network service such as a human operator, directory enquiries, emergency services etc.country_codeβ returns44.regulatorβ returns informational text.areacodeβ return the area code β if applicable β for the number. If not applicable, returnsundef.areanameβ return the area name β if applicable β for the number, orundef.locationβ for geographic numbers, this returns the location of the exchange to which that number is assigned, if available. Otherwise returnsundef.subscriberβ return the subscriber part of the number.operatorβ return the name of the telco operating this number, in an appropriate character set and with optional details such as their web site or phone number.formatβ return a sanely formatted version of the number, complete with IDD code. eg for the UK number(0208) 771-2924it would return+44 20 8771 2924. Chef's kiss formatting π§intra_country_dial_toβ within the UK numbering plan you can always dial0xxxx xxxxxxfor intra-country calls. In most places the leading0$areacodeis optional but in some it is required (see eghttps://www.ofcom.org.uk/__data/assets/pdf_file/0017/19160/aberdeen_local_dialling_release.pdf) and over time this will apply to more areas.countryβ if the numberis_international, return the two-letter ISO country code.
NYI π§
π LIMITATIONS/BUGS/FEEDBACK π
The results are only as up-to-date as the data included from OFCOM's official documentation of number range allocations. So like, if OFCOM sneezed and changed something yesterday, we might not know yet, no cap.
No attempt is made to deal with number portability.
Please report bugs at https://github.com/DrHyde/perl-modules-Number-Phone/issues, including, if possible, a test case. (a test case, bestie, please, we are begging π₯Ί)
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 2026
and that's the whole page, periodt π this was Number...one::UK(3pm) β perl v5.40.1, dated 2026-06-11 β slay, go forth and validate some phone numbers πβ
π¦ 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