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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Answer: How do I test if an array is empty or not?
by choroba (Cardinal) on Jan 15, 2014 at 23:09 UTC
    Have you tested with an array of size 1?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Answer: How do I test if an array is empty or not?
by dcmertens (Scribe) on Jan 16, 2014 at 02:00 UTC

    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;