Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Answer: How do I test if an array is empty or not?

by dcmertens (Beadle)
on Jan 16, 2014 at 02:00 UTC ( #1070748=note: print w/ replies, xml ) Need Help??

An array in scalar context yields its length, thus comparing an array to zero compares its length to zero, which is what you want. Furthermore, you may as well remove the extra punctuation for the postfix conditional, as the parentheses are not necessary.

print "Array is empty\n." if @array == 0;


Comment on Re: Answer: How do I test if an array is empty or not?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-08-04 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (59 votes), past polls