in reply to keyword query
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!my @phonesearch = grep @name, @phonelisting;
Maybe you wanted:
But I can't really be sure.my @phonesearch; foreach my $name (@names) { push(@phonesearch, grep(/$name/, @phonelisting)); }
-sam
UPDATE: added some parens to make the push/grep line a little more obvious.
|
|---|