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.

Table 4-1. Perl Operator Precedence and Associativity
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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.