Comparison Operators

The comparison operators used by Perl are similar to those used by C, awk, and the csh shells, and are used to specify and compare values (including strings). A comparison operator is most often used within an if statement or loop. Perl has comparison operators for numbers and strings. Table 37.1 shows the numeric comparison operators and their meanings.

Table 37.1. Numeric Comparison Operators in Perl

Image

Table 37.2 shows the string comparison operators and their meanings.

Table 37.2. String Comparison Operators in Perl

Image

Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth 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.