The statement $result = 3, 2, 1 is a LIST in void context with the list consisting of an assignment expression ($result = 3) and two constants:
$ perl -MO=Concise -e '$result = 3, 2, 1;'
8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
7 <@> list vK ->8
3 <0> pushmark v ->4
6 <2> sassign vKS/2 ->7
4 <$> const(IV 3) s ->5
- <1> ex-rv2sv sKRM*/1 ->6
5 <$> gvsv(*result) s ->6
- <0> ex-const v ->-
- <0> ex-const v ->7
Were one to evaluate this entire list expression in scalar context (say $outer = ( $result = 3, 2, 1 );, again only using parentheses for precedence disambiguation) the value in $outer would still be the last element of the list (1). It just so happens in the original that the entire list is in void context so it doesn't matter and that value gets dropped on the floor.
Having said that, I don't think displaying a value set as a side effect of one subexpression of building the entire list shows anything about the value of that entire list were the entire list in a scalar context.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|