in reply to
Re^8: If you believe in Lists in Scalar Context, Clap your Hands

in thread If you believe in Lists in Scalar Context, Clap your Hands

If you can't have a list in a scalar context, how can you have the assignment of a list in scalar context?

Because

*any* operator can be scalar context; it's the context that determines its context, not their operands. Here are a few examples of operators in scalar context:

`scalar ($a + $b); # Addition
scalar (($a) x $b); # Repetition
scalar ($a =~ $b); # Matching
scalar ($a .. $b); # Range/FlipFlop
scalar ($a = $b); # Scalar assignment
scalar (($a) = ($b)); # List assignment
`

Here are some examples of operators in list context:

`say ($a + $b); # Addition
say (($a) x $b); # Repetition
say ($a =~ $b); # Matching
say ($a .. $b); # Range/Flipflop
say ($a = $b); # Scalar assignment
say (($a) = ($b)); # List assignment
`

One should realise that 'scalar assignment' and 'list assignment' are two different operators (sassign and aassign in pp_hot.c). It's the LHS of the '=' that determines which operator it is (this is unlike the '..' operator where it's the context that determines whether it's the range or the flipflop operator). The side-effects (that is, the actual assignment) of both sassign and aassign are independent of the context. However, the return value of the aassign operator

*is* context dependent. In scalar context, it returns the number of elements appearing on its RHS.