in reply to Re^3: Perl program to look into the phone directory and in case of a match, print the name along with the number
in thread Perl program to look into the phone directory and in case of a match, print the name along with the number

Hauke D, you are completely right!

My regex required at least one "space" character after the "name". A line ending ("\n" in Perl lingo) counts as a "space" character although in Windows "\n" might actually be a couple of characters.

This regex also appears to work.

next unless ($name,$phone) = $line =~/^\s*([a-zA-Z]+)\s*(\d+)?/;
Thanks haukex!
  • Comment on Re^4: Perl program to look into the phone directory and in case of a match, print the name along with the number
  • Download Code