in reply to Newbie question - imposing context
Why would the assignment of a list in scalar context
There's no list assignment in scalar context in your code. The assignment ("=") in each snippets is a list assignment evaluated in void context. "=>" is not an assignment, it's a fancy version of ",".
You forced the list/comma operator to be evaluated in scalar context, and the list/comma operator in scalar context returns its last element. (Speaking loosely, see perlop for details.)
In line 1 below, the parens around $a1 force a scalar context.
It's the opposite. They force the selection of the list assignment operator, which in turn applies a *list* context to both its LHS and RHS operands. See Mini-Tutorial: Scalar vs List Assignment Operator.
|
|---|