in reply to keyword query

Your problem is on this line:
my @phonesearch = grep @name, @phonelisting;
I'm not exactly sure what you expect that line to do, but I bet it's not what it does! The grep function takes two arguments - an expression and a list. Each member of the list is then evaluated using that expression. In this case you gave it the expression (!) @name and then evaluated each item of @phonelisting using it!

Maybe you wanted:

my @phonesearch; foreach my $name (@names) { push(@phonesearch, grep(/$name/, @phonelisting)); }
But I can't really be sure.

-sam

UPDATE: added some parens to make the push/grep line a little more obvious.