in reply to Re: perl performance vs egrep
in thread perl performance vs egrep

Would it give a speed improvement to prepare the regex in advance with qr//?
No, it wouldn´t. At least not as long the regex is, like here, the only one within the loop. The qr//-operator is useful when you have the need of matching the same string to multiple regexes/patterns, like in
@p = ( qr/^abc/, qr/abc$/, ); for $f ( @foo ) { for $p ( @p ) { do_stuff() if $f =~ $p; } }
Using qr// doesn´t even help in code like
while ( $foo =~ /^abc/ && $foo =~ /abc$/ ) { do_stuff(); }
because in such a case internal perl optimizations come into play.

holli, regexed monk