in reply to Re^3: Substitution with regex and memory consumption
in thread Substitution with regex and memory consumption

Isn't this behavior incorrect? Why we must copy variable on each substitution?

I think we can: respect PL_sawampersand and /p flag for substitution and have only one copy for string (last one) in current scope.

  • Comment on Re^4: Substitution with regex and memory consumption

Replies are listed 'Best First'.
Re^5: Substitution with regex and memory consumption
by dave_the_m (Monsignor) on Mar 08, 2020 at 11:51 UTC
    As always the devil is in the detail. Consider for example:
    { $s = ".....X....."; $s =~ s/X/Y/; $x = eval q{ "[ $`$& $' ]" }; }
    You can't rely on PL_sawampersand.

    Dave.