Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: if (defined %hash) deprecated

by Rudolf (Monk)
on Oct 15, 2012 at 16:13 UTC ( #999112=note: print w/ replies, xml ) Need Help??


in reply to if (defined %hash) deprecated

This is definetly one of those things that I aswell have wondered about. I've been forced to search the hash to see if any items where inside (or check it's buckets by assigning a scalar). Knowing that (%hash) acts like it should is a nice tidbit! thanks for the post.


Comment on Re: if (defined %hash) deprecated
Replies are listed 'Best First'.
Re^2: if (defined %hash) deprecated
by AnomalousMonk (Abbot) on Oct 15, 2012 at 19:02 UTC
Re^2: if (defined %hash) deprecated
by Ralesk (Pilgrim) on Oct 16, 2012 at 08:12 UTC

    By assigning to a scalar or by checking truthiness, you’re forcing a scalar context, so it can be expected to behave the same – that is, return a falsy value (0) when empty and non-falsy when not (and all the bucket counts are non-falsy). Same goes for arrays which report number of elements when not wantarray.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-07-29 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls