Comparison operators
- Two different types of operators: string and numeric
- Perl decides based on context
- The ones with letters are for strings. The ones without letters are
for numbers.
Comparison
operators |
Comparison |
Numeric |
String |
Equal |
== |
eq |
Not equal |
!= |
ne |
Less than |
< |
lt |
Greater than |
> |
gt |
Less than or equal to |
<= |
le |
Greater than or equal to |
>= |
ge |
Three-way compare |
<=> |
cmp
|
Make sure you're comparing your strings and numbers appropriately.
7 < 30 is
true "7" lt "30" is
false
|
|
|