Arritmetic operators are means of executing basic arithmetic equations inside of your scripts. Perl can perform addition, subtraction, multiplication, division, exponents, or modulus remainders.
PERL Arithmetic:
#!/usr/bin/perl
print "content-type: text/html \n\n"; #the header
$x = 81; #the variable
$add = $x + 9;
trong>arithmatic.pl:
81 plus 9 is 90
81 minus 9 is 72
81 times 10 is 810
81 divided by 9 is 9
81 to the 5th is 3486784401
81 divided by 79 has a remainder of 2
Arithmetic Operators:
Operator Example Result Definition
+ 7 + 7 = 14 Addition
- 7 - 7 = 0 Subtraction
* 7 * 7 = 49 Multiplication
/ 7 / 7 = 1 Division
** 7 ** 7 = 823543 Exponents
% 7 % 7 = 0 Remaind
PERL - Assignment Operators
Assignment operators are for use with variables. In this example, we set our variable ($x) equal to 5. Using assignment operators we can increment it using several of our arithmetic operators from above. Each time we preform an operation, the variable holds the new value because of the assignment operator. Here's the code we used to show this example.
PERL Assignment:
#!/usr/bin/perl
print "content-type: text/html \n\n"; #the header
$x = 5; #the variable
print 'Our $x plus 10 is '.($x += 10);
print "
$x is our new variable value";
print '
Our $x minus 3 is '.($x -= 3);
print "
$x is our new variable value";
print '
Our $x times 10 is '.($x *= 10);
print "
$x is our new variable value";
print '
Our $x divided by 10 is '.($x /= 10);
print "
$x is our new variable value";
print '
the remainder of Our $x divided by 10 is '.($x %= 10);
print "
$x is our new variable value";
print '
Our $x to the tenth power is '.($x **= 10);
print "
$x is our new variable value";
Each time an assignment operation is performed our variable ($x) is permanently changed to a new value for $x is used in the lines following.
assignments.pl:
Our $x plus 10 is 15
15 is our new variable value
Our $x minus 3 is 12
12 is our new variable value
Our $x times 10 is 120
120 is our new variable value
Our $x divided by 10 is 12
12 is our new variable value
the remainder of Our $x divided by 10 is 2
2 is our new variable value
Our $x to the tenth power is 1024
1024 is our new variable value
Assignment Operators:
Operator Definition Example
+= Addition ($x += 10)
-= Subtraction ($x -= 10)
*= Multiplication ($x *= 10)
/= Division ($x /= 10)
%= Modulus ($x %= 10)
**= Exponent ($x **= 10)
PERL - Logical & Relational Operators
Relationship operators relate one variable to another, 5
Read More
http://www.nueva-design.com/nvd/Server-Side-Coding/PERL-Tutorial/Perl-Tutorial-80.html



