Scalar context
Perl has a concept called context, and the context that is evaluated as a scalar is called a scalar context .
Assignment to a scalar variable
Assignment to a scalar variable is a scalar context. Array returns the length of the array when evaluated in a scalar context.
my $num = @values;
Comparison operator term
The left and right terms of comparison operator are scalar contexts.
$x <@values $x == @values
I often see it in the loop of for statement.
for (my $i = 0; $i < @nums; $i++) { ... }
if condition part
The conditional part of if is the scalar context. In the following, @values is evaluated in scalar context, so it returns the number of arrays.
if (@values) { ... }