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 O’Reilly online learning.

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