Hi,
your @b array is not empty, it has one element which happens to be undef. If you run something like:
print scalar @b;
it will print 1, which is why, if you evaluate the array in boolean context (
... if (@b);) you get a true value and your sentence is printed.
If you want to check if the array contains at least one defined element, yes, you probably have to do ... if grep { defined($_) } @b; or something similar. You may want something else, though, if your array is large.
Update: corrected a typo.