in reply to Re: array testing
in thread array testing
You want to use the 'defined' function to test if your array contains anything.I don't think so. See this code modified from yours:
which prints:@three = (1); @three = (); if (defined(@three)) { print "Array three is defined.\n"; }
Array three is defined.(perl 5.6.1)
This is the reason why using defined in aggregates (= arrays and hashes) is deprecated. Quoting from perlfunc:
Use of "defined" on aggregates (hashes and arrays) is deprecated. It used to report whether memory for that aggregate has ever been allocated. This behavior may disappear in future versions of Perl.That's what you're seeing here: array @three has been used, and hasn't completely been freed. A useless test, this "defined(@array)", if you ask me.
|
|---|