in reply to Re: substrings that consist of repeating characters
in thread substrings that consist of repeating characters

IIRC, once perl sees $& anywhere in the program code, it starts to populate that variable (and $' and $`) for all the regular expression matches in the program. Using it impacts the performance of all the regular expressions in the code, not just those ones where it is actually needed!

Replies are listed 'Best First'.
Re^3: substrings that consist of repeating characters
by Eily (Monsignor) on Sep 29, 2020 at 13:16 UTC

    perlvar does mention the issue, but it also says this has been fully fixed since v5.20.

    Edit: so this would mean that you might still get the same relative positions for the different versions on older version of perls, because although $& would be significantly worse than the other solutions on their own, it would actually lower the performances of all other versions when used in the benchmark.