in reply to pattern matching an array

If @reqs contains simple string to match the complete line rather than regexes or partial matches, the you could create a hash and do a fast lookup.

%reqs; @reqs{ @reqs } = (); for( @lines ) { if( /^\*R/ && $_ !~ /BADSTRING/ && exists $reqs{ $_ } ) { # do something } }

Lots of ifs, but much quicker when they are true.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller