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;In reply to Re: Answer: How do I test if an array is empty or not?
by dcmertens
in thread How do I test if an array is empty or not?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |