Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Strange memory growth

by Anonymous Monk
on Feb 15, 2018 at 14:13 UTC ( [id://1209221]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Strange memory growth
in thread Strange memory growth

No difference between exists and defined in this regard. In both cases, the *intermediate* levels will spring into existance. The last level isn't dereferenced as a hash.

If you have perl installed, you can try it out yourself:

$ perl -e 'use Data::Dump; exists $a->{foo}{bar}; dd $a;' { foo => {} } $ perl -e 'use Data::Dump; defined $a->{foo}{bar}; dd $a;' { foo => {} }

Replies are listed 'Best First'.
Re^4: Strange memory growth
by Anonymous Monk on Feb 16, 2018 at 14:46 UTC
    I guess that I'm still confused. When I look at Huck's solution, I see that short-circuit conditional expression optimization will stop the evaluation at the first "false" result. Therefore, as far as I can see, no auto-vivification would occur. My question was therefore whether it actually mattered which function-call Huck used.
      Yes that is true, the function used does not matter. The solution from huck is fine. I updated my original post with a similar example.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2026-05-11 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.