in reply to Re^2: grep trouble
in thread grep trouble
Are those patterns simple words? If yes you could consider constructing an or-regex:
DB<100> @patterns=qw#one two three# DB<101> $str="one two" DB<102> $re=join "|",@patterns DB<103> print $str =~ m/($re)/g onetwo
UPDATE:
just noticed there are still subtle differences:
DB<106> $str="two one two" DB<107> print $str =~ m/($re)/g twoonetwo DB<108> print grep {$str=~/$_/} @patterns onetwo
Cheers Rolf
|
|---|