#!/usr/bin/perl

#################################################
# PROGRAM: Parse Phone Numbers (PPN) V1.0
#
# PPN reads lines from standard input and if the
# line contains a phone number, prints out the
# area code, first block and second block of the
# number.  Only the first number on any line is
# processed.
#################################################

while(<>)
{
  $line = $_;
  if ($line =~ /(1|1\-|1\w)?((\d\d\d)|\((\d\d\d)\))(\-|\s)?(\d\d\d)(\-|\s)?(\d\d\d\d)/)
  {	
    $ac = $3.$4;
    $b1 = $6;
    $b2 = $8;
    print "area code is $ac\n";
    print "block one is $b1\n";
    print "block two is $b2\n";
  }
}