#!/usr/bin/perl

my %entry;

while (<STDIN>)
{
   if (!(/^$/))
   {
      # non-empty line
      chomp;   # remove trailing newline
      /:/;     # match the colon = key:value separator
      $entry{$`} = $';   # key = "left of match", value = "right of match"
   }
   else
   {
      # empty line (separator)
      my @hashkeys = keys %entry;
      if ($#hashkeys + 1 > 0)
      {
         # the hash table has accumulated some data = is non-empty
         print $entry{"TEL;TYPE=PREF,VOICE"} . "\t" . $entry{"FN"} . "\n";

         %entry = ();  # clear the hash table
      }
      # else the hash table is empty, do nothing
   }
}

