Operators
Here are lists of the most commonly used operators and their meanings, with examples.
Table 1. Arithmetic operators
| Operator | Meaning | Example |
| + | addition | $a + $b |
| - | subtraction | $a - $b |
| * | multiplication | $a * $b |
| / | division | $a / $b |
| % | modulus | $a % $b |
| ++ | increment | $a++ |
| -- | decrement | $a-- |
Table 2. Logical operators
| Operator | Meaning | Example |
| && | and | $a && $b |
| || | or | $a || $b |
| ! | not | !$a |
Table 3. Assignment operators
| Operator | Meaning | Example |
| = | assign | $a = $b |
| += | add to | $a +=1 |
| -= | subtract from | $a -=1 |
| .= | append | $str.="foo" |
Table 4. Relational operators used in string context
| Operator | Meaning | Example |
| eq | equivalent | $str eq "foo" |
| ne | not equivalent | $str ne "foo" |
| gt | greater than | $str gt "123" |
| lt | less than | $str lt "123" |
| ge | greater than or equal to | $str ge "123" |
| le | less than or equal to | $str le "123" |
Table 5. Relational operators used in numeric context
| Operator | Meaning | Example |
| == | equivalent | $num == 100 |
| != | not equivalent | $num! = 100 |
| > | greater than | $num>100 |
| < | less than | $num<100 |
| >= | greater than or equal to | $num>=100 |
| <= | less than or equal to | $num<=100 |