>perl -MO=Concise -e"$a=1"
6 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
5 <2> sassign vKS/2 ->6 <--
3 <$> const[IV 1] s ->4
- <1> ex-rv2sv sKRM*/1 ->5
4 <#> gvsv[*a] s ->5
-e syntax OK
>perl -MO=Concise -e"($a)=1"
8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
7 <2> aassign[t2] vKS ->8 <--
- <1> ex-list lK ->5
3 <0> pushmark s ->4
4 <$> const[IV 1] s ->5
- <1> ex-list lK ->7
5 <0> pushmark s ->6
- <1> ex-rv2sv sKPRM*/1 ->-
6 <#> gvsv[*a] s ->7
-e syntax OK
ssassign evaluates its RHS in scalar context, then evaluates its LHS in scalar context, then performs the assignment, then returns the value returned by the RHS.
asassign evaluates its RHS in list context, then evaluates its LHS in list context, then performs the assignment, then returns either the value returned by the RHS (in list context) or the number of scalars returned by the RHS (in scalar context).
>perl -le"print( scalar( $a=5 ) );"
5
>perl -le"print( scalar( ($a)=5 ) );"
1
If not please show me code that showes that ($a) is not a list.
I didn't say it wasn't. The list assignment operator forces its arguments to be lists. For example, there are two lists in @a = 4.
>perl -MO=Concise -e"@a=4"
9 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
8 <2> aassign[t3] vKS ->9
- <1> ex-list lK ->5 <---
3 <0> pushmark s ->4
4 <$> const[IV 4] s ->5
- <1> ex-list lK ->8 <---
5 <0> pushmark s ->6
7 <1> rv2av[t2] lKRM*/1 ->8
6 <#> gv[*a] s ->7
-e syntax OK
Notice how the LHS is a list even though there's no parens? You're confusing cause and effect.
"($a)" is a list because "=" is a list assignment operator.
"=" being a list assignment operator isn't caused by "($a)" being a list.
The parens only *indirectly* causes the change in context.
|