in reply to How to determine if an array contains an undef value?

An array containing an undef is not empty; it contains the undef. In that case @array in a scalar context (eg. if( @array ); returns the number of elements, which is 1, therefore true.

It may be an undefined value, but it is still a value.

So, based upon what you've said, your problem becomes not: Is the array empty?; but rather: Does the array contain any defined values?

Whilst that can be determined with grep, and may be perfectly adequate if your arrays are known to be small; if there is any chance that you could be dealing with large arrays that might contain lots of undefs, then you might also consider using one of the any() implementations (eg. List::Util::any() ) which will short circuit when it sees the first defined value:

print "\@b is not Empty any\n" if any { defined() } @b;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: How to determine if an array contains an undef value?
by thanos1983 (Parson) on Jan 04, 2015 at 22:28 UTC

    It makes more sense now. Thank you for your time and effort reading and replying to my question.

    Seeking for Perl wisdom...on the process of learning...not there...yet!