scalar((1,2,3))
has no list in it. The confusion is that we (English speakers) "list" things by separating them using commas. From Perl's perspective, there is nothing in that statement to provide a list context. "scalar" can take any expression, and just sees comma separators, no matter how many sets of parentheses you surround it with.
scalar(()=(1,3,5))on the other hand, has an assignment that forces a list context, so the answer becomes "3".
if( ($k, $v) = ( 1, 0 ) )works the same way. The left side of the assignment is now a list, because of the equals sign. The overall context of any boolean test is scalar, so that an "if list" always provides the element count.
In reply to Re: list assignment to list in scalar context
by Anonymous Monk
in thread list assignment to list in scalar context
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |