You probably want to use word boundary anchors so that you don't get false positives with fprintf when looking for int etc.
I agree. In other words, break the text into words before attempting to match entire words. So all the regex engine is doing is replicating an inner for-loop with an eq test.
while ( <> ) { for my $word ( m{\b(\w+)\b}g ) { if (grep {$word eq $_} @prims) { print qq{Found $word on line $.\n}; } } }
Update: which, of course, vindicates thezip's hash-based solution in the first response to this question.
In reply to Re^2: Pattern match array
by Narveson
in thread Pattern match array
by aennen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |