# Perl Assignment Operators

PERLServer Side ProgrammingProgramming Scripts

Assume variable $a holds 10 and variable$b holds 20, then below are the assignment operators available in Perl and their usage −

Sr.No.Operator & Description
1=
Simple assignment operator, Assigns values from right side operands to left side operand
Example−$c =$a + $b will assigned value of$a + $b into$c
2+=
Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand
Example−$c +=$a is equivalent to $c =$c + $a. 3-= Subtract AND assignment operator, It subtracts right operand from the left operand and assigns the result to left operand Example−$c -= $a is equivalent to$c = $c -$a
4*=
Multiply AND assignment operator, It multiplies right operand with the left operand and assigns the result to left operand
Example−$c *=$a is equivalent to $c =$c * $a. 5/= Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand Example−$c /= $a is equivalent to$c = $c /$a
6%=
Modulus AND assignment operator, It takes modulus using two operands and assigns the result to left operand
Example−$c %=$a is equivalent to $c =$c % a
7**=
Exponent AND assignment operator, Performs exponential (power) calculation on operators and assign value to the left operand
Example−$c **=$a is equivalent to $c =$c ** \$a
Published on 29-Nov-2019 06:15:04