That's completely wrong.
Precedence indicates where implied parentheses are located. Precedence mere dictates that $c, $c += 1 is short for $c, ($c += 1) rather than ($c, $c) += 1. Precedence is not relevant.
Operand evaluation order dictates which of $c and $c += 1 is evaluated first. Since operand evaluation order is left-to-right for the list/comma operator, $c is evaluated before $c += 1, so you got the order wrong too.
You can see the LTR order in the compiled code:
>perl -MO=Concise,-exec -e"my @a = ( $c, $c += 1 );" 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> pushmark s 4 <#> gvsv[*c] s # $c 5 <#> gvsv[*c] s # $c + 1 6 <$> const[IV 1] s # 7 <2> add[t4] sKS/2 # 8 <0> pushmark s 9 <0> padav[@a:1,2] lRM*/LVINTRO a <2> aassign[t5] vKS/COMMON b <@> leave[1 ref] vKP/REFC -e syntax OK
You can see the LTR order in this example:
my $c = 4; sub c :lvalue { print("$_[0]\n"); $c } my @a = ( c("a"), c("b") += 1 ); print("@a\n");
outputs
a b 5 5
In reply to Re^2: Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?
by ikegami
in thread Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?
by smls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |