in reply to passing an array without a name to pop()
However, (2,4,6) clearly isn't a scalar.
Actually, it is.
Well, it's a Perl expression. But it's a scalar in the same sense that 3+5 is a scalar because it evaluates to scalar.
In scalar context, (2,4,6) evaluates to the single scalar 6. That is the case here.
In list context, (2,4,6) evaluates to the three scalars 2, 4 and 6. That is not the case here.
The block is expected to return a single scalar that is a reference, so it's evaluated in scalar context, so the last statement of the block is evaluated in scalar context.
|
|---|