Operators are special symbols that allow the compiler to perform mathematical and logical manipulations. Operators supported by Perl include:
Arithmetic operators allow addition, subtraction, multiplication, and division.
Equality operators (also called relational operators) allow us to compare values or variables. They return boolean values.
Logical operators connect expressions to find a compound result. They return boolean values.
Assignment operators allow values to be stored in a variable. They can be used in conjunction with arithmetic operators.
Bitwise operators work bit-by-bit, performing the operation on corresponding bits.
Quote-like operators manipulate strings.
The following code shows how some of these operators can be used.
# arithmetic operators$x = 10;$y = 3;print $x+$y,"\n";print $x-$y,"\n";print $x*$y,"\n";print $x/$y,"\n";print $x%$y,"\n";print $x**$y,"\n";# assignment operators$a = 25;$b = 8;$a += $b;print $a,"\n";$a -= $b;print $a,"\n";$a *= $b;print $a,"\n";$a /= $b;print $a,"\n";$a %= $b;print $a,"\n";$a **= $b;print $a,"\n";
Free Resources