Number::Phone::US - Validate US-style phone numbers


Number-Phone-US documentation  | view source Contained in the Number-Phone-US distribution.

Index


NAME

Top

Number::Phone::US - Validate US-style phone numbers

SYNOPSIS

Top

  use Number::Phone::US qw(is_valid_number);

  &do_that_thing if is_valid_number($input);

DESCRIPTION

Top

Number::Phone::US is a simple module to validate US-sytle phone number formats.

Currently marks as valid, phone numbers of the following forms:

	 (734) 555 1212
	 (734) 555.1212
	 (734) 555-1212
	 (734) 5551212
	 (734)5551212
	 734 555 1212
	 734.555.1212
	 734-555-1212
	 7345551212
	 555 1212
	 555.1212
	 555-1212
	 5551212
	 5 1212
	 5.1212
	 5-1212
	 51212

Currently marks as invalid, phone numbers of the following forms:

         734-555.1212
         734-5551212

validate_number($ )

Use like

  if ( validate_number($number) ) { &foo; }

returns true if $number is a properly formatted US phone number. does _not_ check and see if $number is a functioning number, although maybe it should.

this function can also be called as: is_valid_number($number)

get_regex ()

Use like

  $rough_regex = get_regex;
  if ( $phone =~ /$rough_regex/o ) { &foo }

returns the rough regex string (does not enforce phone number consistency.)

COPYRIGHT

Top

SEE ALSO

Top

perl(1)

AUTHOR

Top

Hugh Kennedy <kennedyh@engin.umich.edu>

     __|   \   __|  \ |
    (     _ \  _|  .  |
   \___|_/  _\___|_|\_|


Number-Phone-US documentation  | view source Contained in the Number-Phone-US distribution.