in reply to Impact of special variables on regex match performance

It looks like the thing that surprises you is that you are paying the price for the special vars, when you haven't been using them. But it can't tell for sure that you won't have something like:
my $one = one; eval "uncomment_$one()";
So it has to play safe. Note that the following code goes wrong, because it can't see the magic var.
'abc' =~ m/b/; print( eval( '$`') , "\n")

Replies are listed 'Best First'.
Re^2: Impact of special variables on regex match performance
by roubi (Hermit) on Dec 10, 2010 at 20:15 UTC
    What surprised me was the magnitude of the performance degradation here, compared to other code doing a similar number of matches on the exact same output (the multi-line approach I briefly mention at the bottom of my post). JavaFan explained why that is the case.