http://www.perlmonks.org?node_id=1070748


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

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;