NAME

Number::Phone::Normalize - Normalizes format of Phone Numbers.

SYNOPSIS

use Number::Phone::Normalize;

print phone_intl('+1 (555)  123     4567');			# +1 555 1234567
print phone_local('+49-89-99999999','CountryCode'=>'49');	# 089 99999999

DESCRIPTION

This module takes a phone (or E.164) number in different input formats and outputs it in accordance to E.123 or in local formats.

Functions and Methods

phone_intl( $number, %params )

Normalizes the phone number $number and returns it in international (E.164) format. $number can be in an international format or in a local format if the CountryCode/AreaCode parameters are supplied.

If phone_intl does not have enough information to build an international number (e.g. neither $number does not contain a country code and %param does not specify a default), it returns undef.

phone_local( $number, %params )

Normalizes the phone number $number and returns it in local format. $number can be in an international format or in a local format if the CountryCode/AreaCode parameters are supplied.

If phone_local does not have enough information to build an international number (e.g. neither $number does not contain a country code and %param does not specify a default), it returns undef.

Parameters

Interpreting $number

These parameters specify how the input $number is interpreted if it is in a non-international format.

CountryCode

The local country code. It is added to phone numbers in local format without an country code.

AreaCode

The local area code. It is added to phone numbers in local format without an area code.

IntlPrefix

The international prefix. If $number starts with this prefix, the country code and area code are taken from the number.

The default is '00' (ITU recommendation).

LDPrefix

The long distance prefix. If $number starts with this prefix, the area code is taken from $number and the country code is taken from the CountryCode parameter.

If $number starts with neither IntlPrefix nor LDPrefix, it is assumed to be in local format and both country and area codes are taken from the parameters.

The default is '0' (ITU recommendation).

Formatting output

These parameters specify how the output is formatted. Most parameters only have an effect on output in local format.

CountryCodeOut

The local country code. If the number does not have the CountryCode specified, it is returned starting with the IntlPrefix.

AreaCodeOut

The local country code. If the number does not have the CountryCode specified, it is returned starting with the LDPrefix.

IntlPrefixOut

The international prefix for output. If the number is not in the country specified by CountryCode, the returned number will start with this prefix.

The default is IntlPrefix.

You can set this parameter to '+' in order to return numbers in international format instead of the local format.

LDPrefixOut

The long distance prefix for output. It the number is not in the area specified by AreaCode or AlwaysLD is set to true, it is returned starting with LDPrefixOut.

The default is LDPrefix.

AlwaysLD

If set to true, the number will always be returned with an area code, even if it is in the country and area specified by CountryCode and AreaCode.

VanityOK

If set to true, vanity numbers will not be converted to numeric format.

BUGS AND LIMITATIONS

The module does not support more complex dialling plans. It is mostly intended for data input/output to and from databases, not for actually dialling numbers.

AUTHOR

Claus Färber <perl@cfaerber.name>

COPYRIGHT

Copyright © 2004-2006 Claus Färber

It is free software; you can redistribute it and/or modify it under the terms of either the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or the "Artistic License".

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 339:

'=item' outside of any '=over'

Around line 348:

You forgot a '=back' before '=head1'

Around line 355:

Non-ASCII character seen before =encoding in 'Färber'. Assuming UTF-8