in reply to if (defined @arr) problem

What happened is that you returned a list containing one element - the element being undef. So, @a is a one element array, and hence is certainly defined.

The Perl documentation warns you about using defined on aggregates. Usually, Perl is very DWIM, but in this case, it isn't. The return values are usually surprising, and while p5p has talked about changing this, it hasn't happened yet.

If you want to find out whether an array has elements in it, just use the array in boolean (scalar) context. It will return a true value if there are elements in it, or else it will return a false value.

Perl --((8:>*