"be consistent" | |
PerlMonks |
Re^2: Idiom to return 0 or random number of array elementsby LanX (Saint) |
on Dec 07, 2012 at 05:46 UTC ( [id://1007688]=note: print w/replies, xml ) | Need Help?? |
@array[0 ..0] is one and not zero elements!
UPDATE: your statistical proof falls into the trap scalar @array != scalar (LIST) if your function() returns a one element list (0), then scalar function() will be 0, since 0 is the last element of the list. (more detailed in Re^2: Idiom to return 0 or random number of array elements by eyepopslikeamosquito ) initializing @array = 1..10 makes it more obvious, b/c the last element of a sublist is now identical to the length!
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|