Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by merlyn (Sage)
on Nov 12, 2000 at 16:42 UTC ( [id://41181]=note: print w/replies, xml ) Need Help??


in reply to How do I test if an array is empty or not?

The name of the array (like @a) in a scalar context yields the number of elements currently in the array. And a boolean test selects scalar context automatically, so something like:
if (@a) { # @a is not empty... ... } else { # @a is empty ... }
should work just fine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found