Ahem.
Remember the following important rule: There is no rule that relates the behavior of an expression in list context to its behavior in scalar context, or vice versa. It might do two totally different things. Each operator and function decides which sort of value it would be most appropriate to return in scalar context. Some operators return the length of the list that would have been returned in list context. Some operators return the first value in the list. Some operators return the last value in the list. Some operators return a count of successful operations.In general, they do what you want, unless you want consistency.
- Larry Wall, the Perl functions manual page, perlfunc
Oh, and -
Never write $$a[$i] when you mean ${$a[$i]} or @$a[$i] when you mean @{$a[$i]}. Those won't work at all.- Tom Christiansen, The Perl Data Structures Cookbook section 0, General tips (abbreviated)
Case closed.