Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by haukex (Bishop)
on Dec 20, 2019 at 18:34 UTC ( #11110446=note: print w/replies, xml ) Need Help??


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 (Cardinal) on Dec 20, 2019 at 18:41 UTC
Re^3: unexpected modify hash in a distance with grep { $_ }
by LanX (Cardinal) on Dec 20, 2019 at 22:47 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2020-11-25 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?