in reply to Re: Regexes that use a string as basis for matching
in thread Regexes that use a string as basis for matching

The second snippet shouldn't be any slower. In both snippets, the regexp is compiled once.

However,

my @regexps = ( 'pattern1', 'pattern2', ); for my $s (@strings) { for $re (@regexps) { something($s =~ /$re/); } }

is slower than

my @regexps = ( qr/pattern1/, qr/pattern2/, ); for my $s (@strings) { for $re (@regexps) { something($s =~ /$re/); } }

since the former compiles each regexp for each string, while the latter compiles each regexp once.