in reply to Re: unexpected modify hash in a distance with grep { $_ }
in thread unexpected modify hash in a distance with grep { $_ }

the $_ inside the grep is an alias of the hash-values, i.e. any assignment would be mirrored. For reasons that I don't understand yet (under-coffeination perhaps) this triggers an autovivification.

My educated guess is that it's because autovivification generally happens in an lvalue context.

  • Comment on Re^2: unexpected modify hash in a distance with grep { $_ }

Replies are listed 'Best First'.
Re^3: unexpected modify hash in a distance with grep { $_ }
by LanX (Saint) on Dec 20, 2019 at 18:41 UTC
Re^3: unexpected modify hash in a distance with grep { $_ }
by LanX (Saint) on Dec 20, 2019 at 22:47 UTC