4.2. The Hall of the Precedence
Perl has a complicated precedence ordering; it helps to be able to look it up quickly (fortunately, it's the first thing out of perldoc perlop). We reproduce that table here (Table 4-1) because we'll be referring to it.
Associativity | Operators |
---|---|
Left | Terms and list operators (leftward) |
Left | -> |
Nonassoc | ++ -- |
Right | ** |
Right | ! ~ \ and unary + and - |
Left | =~ !~ |
Left | * / % x |
Left | + - . |
Left | << >> |
Nonassoc | Named unary and file test operators |
Nonassoc | < > <= >= lt gt le ge |
Nonassoc | == != <=> eq ne cmp |
Left | & |
Left | | ^ |
Left | && |
Left | || |
Nonassoc | .. … |
Right | ?: |
Right | = op= |
Left | , => |
Nonassoc | List operators (rightward) |
Right | not |
Left | and |
Left | or xor |
Associativity tells you ...
Get Perl Debugged now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.