Relational Operators
Perl has two classes of relational operators. One class operates on numeric values, the other on string values, as shown in Table 3.5.
Table 3-5. Relational Operators
| Numeric | String | Meaning |
|---|---|---|
> | gt | Greater than |
>= | ge | Greater than or equal to |
< | lt | Less than |
<= | le | Less than or equal to |
These operators return 1 for true
and "" for false. Note that relational operators are nonassociating,
which means that $a < $b < $c is a syntax
error.
In the absence of locale declarations, string comparisons are based on the ASCII/Unicode collating sequences, and, unlike in some computer languages, trailing spaces count in the comparison. With a locale declaration, the collation order specified by the locale is used. (Locale-based collation mechanisms may or may not interact well with the Unicode collation mechanisms currently in development.)
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.
Read now
Unlock full access