| Prev | Perl Notes |
Next |
| Operator | Description | Example |
|---|---|---|
| == | equal to | if ($age == 36) |
| != | not equal to | if ($age != 36) |
| > | greater than | if ($age > 36) |
| < | less than | if ($age < 36) |
| >= | greater than or equal to | if ($age >= 36) |
| <= | less than or equal to | if ($age <= 36) |
| Operator | Description | Example |
|---|---|---|
| eq | equal to | if ($name eq "Ralph") |
| ne | not equal to | if ($name ne "Ralph") |
| gt | greater than | if ($name gt "Ralph") |
| lt | less than | if ($name lt "Ralph") |
| ge | greater than or equal to | if ($name ge "Ralph") |
| le | less than or equal to | if ($name le "Ralph") |
| Operator | Description | Example |
|---|---|---|
| && | logical and operator | if (($name eq "Ralph")&&($age > 45)) |
|
With two comparisons and the logical and operator, the entire condition is true if and only if the value of both comparisons is true. In other words, the person in question must be named Ralph and must be older than 45. | ||
| || | logical or operator | if (($name eq "Ralph")||($age > 45)) |
|
If you use the logical or operator, only one of the comparisons needs to return true for the condition to be true. In this case, persons older than 45, regardless of their name, or people named Ralph, regardless of their age, would match. | ||
| Prev | Home | Next |