Number::Phone::UK - UK-specific methods for Number::Phone


    use Number::Phone;

    $daves_phone = Number::Phone->new('+44 1234 567890');


Number::Phone::UK uses a large database, access via Number::Phone::UK::Data. This database lives in a file, and normally only the little bits of it that you access will ever get loaded into memory. This means, however, that creating Number::Phone::UK objects almost always involves disk access and so is slow compared to data for some other countries. There are two ways to avoid this 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, which will pull the entire database into memory. This will take a few minutes, and on a 64-bit machine will consume of the order of 200MB of memory.

The database uses DBM::Deep. This apparently has 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. This is, of course, not a problem if you slurp() the database before forking.


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('+44 ...').


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.


The number has been allocated to a telco for use. It may or may not yet be in use or may be reserved.


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. See for the authoritative source.


The number refers to a geographic area.


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*).


The number, when in use, can only refer to a mobile phone.


The number, when in use, can only refer to a pager.


Callers will not be charged for calls to this number under normal circumstances.


The number, when in use, attracts special rates. For instance, national dialling at local rates, or premium rates for services.


The number, when in use, goes to a service of an adult nature, such as porn.


The number, when in use, goes to an individual person.


The number, when in use, goes to a business.


The number, when in use, is terminated using VoIP.


The number is some kind of network service such as a human operator, directory enquiries, emergency services etc


Returns 44.


Returns informational text.


Return the area code - if applicable - for the number. If not applicable, returns undef.


Return the area name - if applicable - for the number, or undef.


For geographic numbers, this returns the location of the exchange to which that number is assigned, if available. Otherwise returns undef.


Return the subscriber part of the number


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.


Return a sanely formatted version of the number, complete with IDD code, eg for the UK number (0208) 771-2924 it would return +44 20 8771 2924.


Within the UK numbering plan you can *always* dial 0xxxx xxxxxx for intra-country calls. In most places the leading 0$areacode is optional but in some it is required (see and over time this will apply to more areas.


If the number is_international, return the two-letter ISO country code.



The results are only as up-to-date as the data included from OFCOM's official documentation of number range allocations.

No attempt is made to deal with number portability.

Please report bugs at, including, if possible, a test case.

I welcome feedback from users.


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


David Cantrell <>

Copyright 2012