Quick summary of conditions and comparisons in Perl

Recall, a condition can be thought of as something that is true or false. It is useful as part of control flow constructs such is if, if-else or while.

A condition can be as simple as a scalar value -- a number or a string.

Comparison operators for numbers and strings are also useful.

For numbers For strings Meaning
== eq Equal to
!= ne Not equal to
> gt Greater than
>= ge Greater than or equal to
< lt Less than
<= le Less than or equal to
<=> cmp Less than, equal to, or greater than (-1,0,+1)

Logical operators can be used to negate or combine conditions.

Full rules on operator and comparison precedence can be found here. When in doubt, the simple approach is to use parentheses ().

The ASCII character table: