"be consistent" | |
PerlMonks |
Re^2: Array/List Strangenessby Marshall (Canon) |
on Aug 05, 2009 at 02:29 UTC ( [id://785953]=note: print w/replies, xml ) | Need Help?? |
For a Perl @var, two thing can happen: (a) @var is declared but does not exist in the sense that it is "empty", containing NO values, not even "undef". (b) @var is declared and does exist in the sense that it has "actual values" or undef as one or more values (undef is a value).
my @var = (1,2,3); Yes, this is weird that an @var can have "nothing" in it, not even undef. This @var=() is often seen in code that "zero'es" out a @variable. I have tried to avoid using the term "array" or "list" for these @vars. I remain curious as to when @var is an array and when @var is a list. Update: I prefer the word "list" for Perl @vars because a list can be empty. I don't think of an array as "empty". In my thinking, an array has a null element, null pointer, etc. But the idea that it is "empty", in the same sense that a list can be "empty" (like a completely blank "to-do list) doesn't make sense to me.
In Section
Seekers of Perl Wisdom
|
|