in reply to Perl precedence details
Hello hurricup,
A named unary operator is a built-in function which takes exactly one argument. Examples are chdir and rand. See Named Unary Operators.
The distinction between leftward and rightward list operators is explained in Terms and List Operators (Leftward):
In the absence of parentheses, the precedence of list operators such as print, sort, or chmod is either very high or very low depending on whether you are looking at the left side or the right side of the operator. For example, in
the commas on the right of the sort are evaluated before the sort, but the commas on the left are evaluated after. In other words, list operators tend to gobble up all arguments that follow, and then act like a simple TERM with regard to the preceding expression.@ary = (1, 3, sort 4, 2); print @ary; # prints 1324
In other words, the commas on the right of the sort are evaluated first, because the rightward aspect of the list operator sort has a lower precedence than the comma operator. But the list operator sort is evaluated before the commas to its left, because its leftward aspect has a higher precedence than the comma operator. Prototypes have nothing to do with the difference between leftward and rightward here.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl precedence details
by hurricup (Pilgrim) on Jun 20, 2015 at 10:07 UTC | |
by Athanasius (Archbishop) on Jun 20, 2015 at 13:46 UTC |