in reply to Re: if (defined @arr) problem
in thread if (defined @arr) problem
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: if (defined @arr) problem
by secret (Beadle) on Dec 15, 2005 at 10:49 UTC | |
by davorg (Chancellor) on Dec 15, 2005 at 11:22 UTC | |
by secret (Beadle) on Dec 15, 2005 at 13:32 UTC | |
by blazar (Canon) on Dec 16, 2005 at 10:14 UTC | |
|
Re^3: if (defined @arr) problem
by parv (Parson) on Dec 15, 2005 at 16:58 UTC | |
by bart (Canon) on Dec 15, 2005 at 17:40 UTC | |
by parv (Parson) on Dec 15, 2005 at 18:42 UTC |