Skip to Main Content
Perl in a Nutshell
book

Perl in a Nutshell

by Nathan Patwardhan, Ellen Siever, Stephen Spainhour
December 1998
Beginner to intermediate content levelBeginner to intermediate
674 pages
40h 41m
English
O'Reilly Media, Inc.
Content preview from Perl in a Nutshell

Operators

Table 4.3 lists all the Perl operators from highest to lowest precedence and indicates their associativity.

Table 4-3. Perl Associativity and Operators, Listed by Precedence

AssociativityOperators
LeftTerms and list operators (leftward)
Left -> (method call, dereference)
Nonassociative ++ -- (autoincrement, autodecrement)
Right ** (exponentiation)
Right

! ~ \ and unary + and - (logical not, bit-not, reference, unary plus, unary minus)

Left

=~ !~ (matches, doesn’t match)

Left

* / % x (multiply, divide, modulus, string replicate)

Left

+ - . (addition, subtraction, string concatenation)

Left

<< >> (left bit-shift, right bit-shift)

Nonassociative

Named unary operators and file-test operators

Nonassociative

< > <= >= lt gt le ge (less than, greater than, less than or equal to, greater than or equal to, and their string equivalents.

Nonassociative

== != <=> eq ne cmp (equal to, not equal to, signed comparison, and their string equivalents)

Left & (bit-and)
Left | ^ (bit-or, bit-xor)
Left && (logical AND)
Left || (logical OR)
Nonassociative .. &#133; (range)
Right ?: (ternary conditional)
Right

= += -= *= and so on (assignment operators)

Left , => (comma, arrow comma)
NonassociativeList operators (rightward)
Right not (logical not)
Left and (logical and)
Left or xor (logical or, xor)

You can make your expressions clear by using parentheses to group any part of an expression. Anything in parentheses will be evaluated as a single unit within a larger expression.

With very few exceptions, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl One-Liners

Perl One-Liners

Peteris Krumins
Beginning Perl

Beginning Perl

Curtis Ovid Poe
Mastering Perl

Mastering Perl

brian d foy
Perl Best Practices

Perl Best Practices

Damian Conway

Publisher Resources

ISBN: 1565922867Catalog PageErrata