This tutorials explains about Perl availiable Operators

What are arthmetic operators in Perl

Arithmetic operators are used to calculate arithmetic mathematical operations

  • Addition
  • Substraction
  • Multiplication
  • Division
  • Modulus
  • Exponent

Perl Arithmetic Operator

For example, We have operand1(op1)=6 and operand2(op2)=2 values.

Operation  SymbolDescription  Result
Addition+addition of two operands$op1 + $op2 is 8
Substraction-Substraction of two operands$op1 - $op2 is 4
Multiplication*Multiplication of two operands$op1 * $op2 is12
Division/Division of operand1 by Operand2 of two operands$op1 / $op2 is 3
Modulus%Remainder after division$op1 % $op2 is 0
Exponent**Exponent calculation. Operand1 power of operand2$op1 ** $op2 is 36

Here is an Perl Arithmetic Operator Example

my $op1= 4;
my $op2 = 2;

my $result= $op1 + $op2;
print "Addition of $op1 and $op2 is $result \n";

$result= $op1 - $op2;
print "Substraction of $op1 and $op2 is $result \n";

$result= $op1 * $op2;
print "Multiplication of $op1 and $op2 is $result \n";

$result= $op1 / $op2;
print "Division of $op1 and $op2 is $result \n";

$result= $op1 % $op2;
print "Modulus of $op1 and $op2 is $result \n";

$result= $op1 ** $op2;
print "Exponentation of $op1 and $op2 is $result \n";

Output:

Addition of 4 and 2 is 6 
Substraction of 4 and 2 is 2 
Multiplication of 4 and 2 is 8 
Division of 4 and 2 is 2 
Modulus of 4 and 2 is 0 
Exponentation of 4 and 2 is 16 

What arithmetic operators are used in Perl scripts?

Arithmetic operators in perl allows you to do arithmetic calculations on operands. Addition(+),Multilication,Substraction, Division, Modulus, Exponent(power) operators exists for this.

What are arthmetic operators in Perl

there are 6 operators in Per for arithmetic calculations. Addition(+),Multilication,Substraction, Division, Modulus, Exponent(power) operators exists for this.