That's because the array contains one value : 'undef' .That looks like a string with the text "undef" to me. That's not what the array contains. Instead, it holds an undefined scalar value.
Look at what happens if you do :sub test { return () ; }
Lo and behold, it works!
Still, testing definedness of an array is a very bad idea. Try running this code first:
and now you'll see, the array will be defined (and empty).@a = qw(a b c);
Don't. Do. It.
Definedness of an array is nothing a newbie should ever be concerned about.
In reply to Re^2: if (defined @arr) problem
by bart
in thread if (defined @arr) problem
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |