in reply to Re: Regexes that use a string as basis for matching
in thread Regexes that use a string as basis for matching
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.
|
|---|