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

That's roughly it, yes.

Dave.

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

Replies are listed 'Best First'.
Re^4: Substitution with regex and memory consumption
by k-mx (Scribe) on Mar 08, 2020 at 08:16 UTC

    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.

      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.