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


in reply to Re: To test empty array in perl
in thread To test empty array in perl

print "Array isn't empty.Array Values:@array\n" if($array[0]);

This won't tell you whether the array is empty.

What happens when the first index of array has undef or 0.?

# my @array = (0, undef, 1, 2, 3); my @array = (undef, undef, 1, 2, 3); print "Array isn't empty.Array Values:@array\n" if($array[0]);