The table below summarize the common Perl operators used
in arithmetic and string operations.
|
Operator
|
Name
|
Description
|
Example
|
Result
|
|
+
|
addition |
Sums values together. |
20+30 |
50 |
|
-
|
subtraction |
Subtracts right value from left value. |
20-10 |
10 |
|
*
|
multiplication |
Multiplies values together. |
20*30 |
600 |
|
/
|
division |
Divides left value by right value. |
20/5 |
4 |
|
%
|
modulus |
Remainder of dividing left value by right value. |
20/3 |
2
20 divided by 3 yields 6 (6*3=18) with a remainder of 2
(20-18). |
|
**
|
exponential |
Raises the left value to the power of the
right value. |
20**2 |
400
Equivalent to 20*20 |
|
.
|
string concatenation |
Chains together the characters in each value. |
"hot"."dog"
"hot "."dog" |
"hotdog"
"hot dog" |
|
x
|
string replicate |
Repeats the characters in left value the right
value number of times. |
"*"x5
"*"x5."Hello"."*"x5 |
*****
*****Hello***** |