Your right that a single operator is created for the entire string of commas. Your snippet doesn't prove that, but -MO=Concise does.
>perl -MO=Concise -wle"print scalar(1,2,3,)" Useless use of a constant in void context at -e line 1. 8 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 7 <@> print vK ->8 3 <0> pushmark s ->4 - <1> scalar sK/1 ->7 6 <@> list sK ->7 <-- one operator 4 <0> pushmark v ->5 - <0> ex-const v ->- \ - <0> ex-const v ->5 |<- three operands 5 <$> const[IV 3] s ->6 / -e syntax OK
But the list operator doesn't return a list in scalar context. No reduction occurs, default or otherwise.
PP(pp_list) { dVAR; dSP; dMARK; if (GIMME != G_ARRAY) { if (++MARK <= SP) *MARK = *SP; else *MARK = &PL_sv_undef; SP = MARK; } RETURN; }
It's the builtin or operator that makes the choice, not the context.
In reply to Re^8: Scalar context of slice (myth)
by ikegami
in thread Scalar context of slice
by thenaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |