http://www.perlmonks.org?node_id=383048


in reply to Why does a Perl 5.6 regex run a lot slower on Perl 5.8?

I am going to guess that you have a UTF-8 LANG set in your environment.

A consequence of this in 5.8.0, but not in 5.6.1 or 5.8.5, is that your file is implicitly opened as UTF-8. This may seem minor, but because you included the /i modifier, it probably slowed it down a lot, since case insensitivity in Unicode is a lot more complicated. You could test this by modifying your environment and rerunning, or by explicitly opening the file as latin-1, or by removing the /i.

You seem to discount the speed up you saw between 5.6.1 and 5.8.5 with your second regex version. I don't think this is really fair. I suspect that the regex engine really is faster in the later versions, when they are actually doing the same thing.

The problem really seems to be that due to some subtleties in how certain things work in different versions of perl, the regex engine is not doing the same things in each of your cases. Since you are so willing to criticize the Perl community, I will gladly turn around and criticize you. This is not particularly obscure information. It's pretty well explained in perldelta, perlunicode, and other man pages. You apparently made the decision to upgrade perl versions without taking the time to research what changed. 5.6 to 5.8 is not a minor change: there are significant changes between the two which you would have been well advised to consider before making the switch.

Furthermore, did you even stop to wonder why there were additional functions being called in one case and not the others? Don't you think this ought to have been a clue that things were not as simple as you would like to think?

  • Comment on Re: Why does a Perl 5.6 regex run a lot slower on Perl 5.8?

Replies are listed 'Best First'.
Re^2: Why does a Perl 5.6 regex run a lot slower on Perl 5.8?
by perldeveloper (Scribe) on Aug 15, 2004 at 13:51 UTC
    I am content about the one thing that I find relevant: my Perl codebase was successfully ported to Perl 5.8.5. My blaming the Perl community and other people's blaming me have both proved besides the point and their only merit -- artistic at most. As seems to always be the case, those people who had only techical points to make were the most useful.