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 (Archbishop)
on Dec 20, 2019 at 18:34 UTC ( [id://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 (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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found