- Context.
- The brackets do not have the role you think when creating the list.
Examples:
$x = 1 + 1;
Roughly speaking, in the context of a list, a comma operator separates the elements of a list; in a scalar context, the comma operator is C "sequential comma", which evaluates its left and right sides and returns the value of the right side. In the scalar context, expressions in parentheses to override the order of operations and in the context of a list, parentheses ... are really the same. The reason they relate to the purpose of arrays is this:
# Comma has precedence below assignment.
As for your question โis it a scalar or a singleton listโ, it just doesnโt make sense to ask the expression in isolation because of the context. In the context of a list, everything is a list; in a scalar context, there is nothing.
Recommended reading: perlop , perldata , Perl Programming.
hobbs
source share