The only way I can keep my sanity in this regard is to repeat the following mantra: there is no such thing as a list in scalar context.
An array in scalar context returns its length. A hash returns its number of buckets. The comma operator returns its right operand, as in my $foo = (1,2,3); A subroutine returns whatever it wants to. Every Perl construct or operator that can be used in an expression does well defined, but sometimes different, things in scalar or list context. See List is a Four-Letter Word.
In reply to Re[3]: difference between \() and []
by Anonymous Monk
in thread difference between \() and []
by eXile
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |