# Operators in Perl

Arithmetic Operator

\$x = 5;

\$y =7;

print \$x + \$y; — Output: 12

• Subtraction: \$x – \$y
• Multiplication: \$x * \$y
• Division: \$x/\$y
• Modulus: \$x%\$y; — Reminder of \$x divided by \$y
• Exponentiation: \$x**\$y

String Operator

\$x =4;

\$y =6;

print \$x.\$y – output – string operator (.) prints the values side by side as 46

print \$x x \$y – string operator (x) will print the value of \$x, \$y times i.e., 4 4 4 4 4 4

Assignment Operator

 Operator Description Example = Assign value to a variable \$x=5; += Add and assign \$x+=3; also means \$x=\$x +3; -= Subtract and assign \$y-=4; also means \$y=\$y-4; *= Multiply and assign \$x*=2; also means \$z=\$z*2; /= Divide and assign \$a/=5; also means \$a = \$a/5; X=3 Print the variable value 3 times \$m x=3; output- “mmm” %= Modulus and assign \$a %= \$b means \$a=\$a % \$b **= Exponential and assign \$a**=\$b means \$a=\$a**\$b

Comparison Operator

 Numeric Operator String Operator Description > gt Greater than < lt Less than == eq Equal to != ne Not equal to >= ge Greater than equal to <= le Less than equal to

Bitwise Operator

 Operator Description & Binary AND Operator | Binary OR Operator ^ Binary XOR Operator ~ Binary 1’S Compliment << Binary Left Shift >> Binary Right Shift

Logical Operator

 Operator Description Results && Logical AND Operator Returns true if both the operands are defined and nonzero || Logical OR Operator Returns true if either of the operands defined and nonzero ! Logical NOT Operator Returns the opposite of the given operand