Operators for Tests and Comparisons

Perl's comparison operators are used to test the relationship between two numbers or two strings. You can use equality tests to see if two scalars are equal, or relational operators to see if one is “larger” than another. Finally, Perl also includes logical operators for making boolean (true or false) comparisons. You'll commonly use the operators for tests as part of conditional and loop operations—ifs and whiles—, which we'll look at some tomorrow and in detail on Day 6, “Conditionals and Loops.”

The Meaning of Truth

No, we're not going to digress into a philosophical discussion here, but before actually going through the operators, you do need to understand just what Perl means by the terms true and false. ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition 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.