in reply to Re: Unrolling the loop technique
in thread Unrolling the loop technique
The problem should become clear by the time it finishes. ;)#!perl -wl use strict; my $good = <<EOT; a quote " with some text after it and then another quote " EOT my $bad = <<EOT; a quote " with some text after it but without another quote EOT my $obvious = qr/"(?:\\.|[^"\\]+)*"/; my $unrolled = qr/"[^"\\]*(?:\\.[^"\\]*)*"/; $| = 1; print "\$good =~ \$unrolled"; print $good =~ $unrolled; print "\$good =~ \$obvious"; print $good =~ $obvious; print "\$bad =~ \$unrolled"; print $bad =~ $unrolled; print "\$bad =~ \$obvious"; print $bad =~ $obvious; print "done";
Jeffrey Friedl goes into much more detail in Mastering Regular Expressions, which is where I grabbed the regexes I used above.
However, if you run this program under perl5.6, you won't have as much time to figure out the issue, because there are improvements to the regex engine in that version which fix the problem!
|
|---|