As you can see, each operator is designed to operate on some specified combination of scalars or lists, and returns either a scalar or a list. If an operator or function expects an operand to be a scalar, we say that the operand or argument is being evaluated in a scalar context . Similarly, if an operand or argument is expected to be a list value, we say that it is being evaluated in a list context .
Normally, the context is fairly insignificant. But, sometimes you get a completely different operation depending on whether you are within a scalar or a list context. For example,
@fred
returns the contents of the
@fred
array in a list context, but the length of the same array in a scalar context. These subtleties are mentioned when each operator and function is described.
A scalar value used within an array context is promoted to a single-element array.