Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

You have to use different comparison operators, depending whether you want to compare arguments numerically or stringwise:

- numerical comparison operators

== returns true if both arguments are numerically equal
!= returns true if both arguments are numerically different
 <=>  returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument
< returns true if left argument is numerically smaller than right argument
> returns true if left argument is numerically bigger than right argument
<= returns true if left argument is numerically smaller or equal than right argument
>= returns true if left argument is numerically bigger or equal than right argument


- string comparison operators

eq returns true if both arguments are stringwise equal
ne returns true if both arguments are stringwise different
 cmp  returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument
lt returns true if left argument is stringwise less than right argument
gt returns true if left argument is stringwise greater than right argument
le returns true if left argument is stringwise less or equal than right argument
ge returns true if left argument is stringwise greater or equal than right argument