| Operator Symbol | Operation |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| ** | Exponentiation |
| % | Modulus (remainder) |
$result = 3 + 5 # Three plus five (will be equal 8) $total = $counter + 5 # Contents of scalar $counter plus five $x = 2 ** 3 # Two to the third power (will equal 8) $a = $a * $c # Contents of $a times the contents of $c $rem = 17 % 7 # Remainder when 17 is divided by 7 (will equal 3)
| Operator Symbol | Operation |
|---|---|
| == | Logical Equal To |
| < | Logical Less Than |
| > | Logical Greater Than |
| <= | Logical Less Than or Equal |
| >= | Logical Greater Than or Equal |
| != | Logical Not Equal |
3 < 5 # Three is less then five (will be true) 2 >= 3 # Two is greater then or equal three (will be false) 17 != 7 # Seventeen is not equal to 7 (will be true)
| Operator Symbol | Operation |
|---|---|
| . | Concatenation (append) |
| x n | Repeat string n times |
$newStr = "Hello" . " World" # Returns string "Hello World" $bike = "Z" . ( "o" x 8 ) . "m" # Returns "Zoooooooom"
| Operator Symbol | Operation |
|---|---|
| eq | Alphabetic Equal To |
| lt | Alphabetic Less Than |
| gt | Alphabetic Greater Than |
| le | Alphabetic Less Than or Equal |
| ge | Alphabetic Greater Than or Equal |
| ne | Alphabetic Not Equal |
$MyName = <STDIN> ; $Greeting = "Hello $MyName\n";
$MyName = <STDIN> chomp $MyName; $Greeting = "Hello $MyName"; print "$Greeting\n"; print STDOUT "How are you?\n";