Jonas B. Nielsen > Business-DK-Phonenumber-0.02 > Class::Business::DK::Phonenumber

Download:
Business-DK-Phonenumber-0.02.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs

Module Version: 0.01   Source   Latest Release: Business-DK-Phonenumber-0.03

NAME ^

Class::Business::DK::Phonenumber - class to model, validate and format Danish telephonenumbers

VERSION ^

This documentation describes version 0.01

SYNOPSIS ^

    use Class::Business::DK::Phonenumber;
    
    #Constructor
    my $phonenumber = Class::Business::DK::Phonenumber->new('+45 12345678');
    
    #Brief human readable Danish phonenumber format with international prefix
    print $phonenumber->render('%02d %02d %02d %02d');
    
    #a brief form validating a stripping everything
    my $phonenum =
        Class::Business::DK::Phonenumber->new('+45 12 34 56 78')->render('%d8');
    # 12345678
    
    #for MSISDN like representation with protocol prefix
    my $phonenum =
        Class::Business::DK::Phonenumber->new('+45 12 34 56 78')->render('GSM%d10');
    # GSM4512345678
    
    #for dialing Denmark with international country prefix and international
    #calling code for calling outside Denmark 00
    my $phonenum =
        Class::Business::DK::Phonenumber->new('12 34 56 78')->render('00%d10');
    # 004512345678

DESCRIPTION ^

This module offers functionality to validate, format and generate Danish phonenumbers using object-oriented programming.

Please see:

The contructor can recognise telephone numbers is the following formats as Danish phonenumbers.

White space characters are ignored. See also "phonenumber".

SUBROUTINES AND METHODS ^

new({ phonenumber => $phonenumber, template => $template })

For valid phone number formatting please refer to "phonenumber".

phonenumber($phonenumber, $template)

This is accessor to the phonenumber attribute.

Provided with a valid phone number parameter the object's phone number attribute is set.

If the accessor is not provided with a phonenumber parameter, the one defined is in the object is returned.

See also: "validate" in Business::DK::Phonenumber, which is used internally to validate the phonenumber parameter.

Valid phone numbers have to abide to the following formatting:

The prefixed plus sign and space used as separator are optional as are the international dialing code.

The phone number can be formatted in anyway separated using whitespace characters.

template($template)

This is accessor to the template attribute.

Provided with a valid template parameter the object's template attribute is set.

If the accessor is not provided with a template parameter, the one defined is in the object is returned.

See also: "validate_template" in Business::DK::Phonenumber, which is used internally to validate the template parameter.

DIAGNOSTICS ^

CONFIGURATION AND ENVIRONMENT ^

No special configuration or environment is necessary.

DEPENDENCIES ^

INCOMPATIBILITIES ^

No known incompatibilities at this time.

BUGS AND LIMITATIONS ^

No known bugs or limitations at this time.

TEST AND QUALITY ^

TODO ^

SEE ALSO ^

sprintf

Business::DK::Phonenumber utilizes sprintf to as templating system for formatting telephonenumbers. This is a well specified and tested interface which is easy to use.

BUG REPORTING ^

Please report issues via CPAN RT:

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Business-DK-Phonenumber

or by sending mail to

bug-Business-DK-Phonenumber@rt.cpan.org

MOTIVATION ^

I have been working in Telco for a long time. So validation and formatting of telephone numbers is something I have seen at lot of. This module is an attempt to sort of consolidate the numerous different regular expression solutions I have seen scathered over large code bases.

AUTHOR ^

Jonas B. Nielsen, (jonasbn) - <jonasbn@cpan.org>

COPYRIGHT ^

Class-Business-DK-Phonenumber is (C) by Jonas B. Nielsen, (jonasbn) 2008-2009

LICENSE ^

Class-Business-DK-Phonenumber is released under the artistic license

The distribution is licensed under the Artistic License, as specified by the Artistic file in the standard perl distribution (http://www.perl.com/language/misc/Artistic.html).