in reply to Re^4: Tokenizing and qr// <=> /g interplay
in thread Tokenizing and qr// <=> /g interplay
then you could do your loop as$_->[0] = qr/\b(\Q$_->[0]\E)b/ for @corrections_to_make;
This way, even if you end up looping over THAT code, you'd still be dealing with already-compiled regexes. As soon as you put additional text into a regex with qr// in it:for my $crummy_good_ar (@corrections_to_make) { my ($crummy, $good) = @$crummy_good_ar; $file_in_string_form =~ s/$crummy/$good/ig; }
Perl has to do the "compare physical regex forms" test. Only if the qr// object is all alone will it have the entire benefits it was made for.my $rx = qr/abc/; if ($str =~ /^($rx)$/) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Tokenizing and qr// <=> /g interplay
by ff (Hermit) on Apr 25, 2005 at 13:37 UTC |