in reply to keyword query

when using grep() the expresion goes first and the search string second. So this my @phonesearch = grep @name, @phonelisting; should be this my @phonesearch = grep /@name/, @phonelisting;

edit:After reading the other replies I went back and looked up grep(). I was thinking it worked exactly like *NIX's grep but it seems I was mistaken. I've changed the above to relect this but I am unsure of the validity of putting an array in a REGEX. I would appreciate any input on this. I still stand by the below block as being my prefered way to preform this search.

Instead of using grep however; I would do your while loop something like this (untested code)
my @phonesearch; my @name =<NL>; chomp(@name); my $name; while(my $phonelisting = <PB>) { chomp($phonelisting); foreach $name (@name) { if ($phonelisting =~ /$name/) { push(@phonesearch,$phonelisting); } } } print OUT "@phonesearch\n";
notice I moved the declaration of @phonesearch outside the loop, this is so the value wouldn't expire when the loop ended. The reasons for my other changes are that using while(1) is a bad idea. It sets you up for an infinite loop and could bite you in a future program if it becomes a habit. Also for this type of application it makes more sense to me to go through the lists one element at a time.

John