Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: list assignment to list in scalar context (boolean)

by tye (Cardinal)
on Nov 09, 2012 at 03:45 UTC ( #1003054=note: print w/ replies, xml ) Need Help??


in reply to list assignment to list in scalar context

List assignment in a scalar context returns the number of items in the right-hand side because that is extremely useful as a Boolean test, as shown in your own example:

while( my( $k, $v ) = each %h ) {

You wouldn't want that loop to terminate early just because one of the values in %h was false.

- tye        


Comment on Re: list assignment to list in scalar context (boolean)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-07 23:59 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 (93 votes), past polls