Perl: the Markov chain saw | |
PerlMonks |
Re: unexpected modify hash in a distance with grep { $_ }by LanX (Saint) |
on Dec 20, 2019 at 18:26 UTC ( [id://11110443]=note: print w/replies, xml ) | Need Help?? |
Hi 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. ° compare Re^2: unexpected modify hash in a distance with grep { $_ } This can easily circumvented with a more common approach to only pass the keys.
Cheers Rolf
°) my guess is it's an implementation detail/bug
In Section
Seekers of Perl Wisdom
|
|