Operators

OPERATORS

Perl may have more operators than any other programming language. The following list is not complete:

=   assignment     #assigns value to variables

MATHEMATICAL OPERATORS

+   addition
-   subtraction
*   multipliation
/   division
**  exponentiation

%   modulus (returns the remainder of an integer division)

++  auto-increment      # increments a variable or integer by 1
--  auto-decrement      # decrements a varaible or integer by 1

If you place the ++ or -- after the variable name, it the variable adds
or subtracts one to itself after it is used or evaluated. If 
you place the operator before the variable name, it the variable adds 
or subtracts one to itself before it is used or evaluated.  Used
most often on loop counters.

LOGICAL OPERATORS

&&  logical AND
||  logical OR

COMPARISON OPERATORS

IMPORTANT:
Perl has a separate sets of comparison operators for strings and numbers.  
Their equivalents are:
numbers strings
==equalityeq
!=inequalityne
<less thanlt
>greater thangt
<=less than or equalle
>=greater than or equalge
STRING CONCATENATION OPERATOR
A . (period) is used add strings together ==>  "abc" . "def"  =  "abcdef"

Operator precedence

Not all operators are created equal. Consider the following statement:

$result =  2 + 3 * 12;

What is the value of $result going to be? It is not going to be 60, but 38. The reason for this is that some operators take precedence over others. The Perl interpreter will not execute the expression from left to right but rather look at all the terms, consider the operators and the values associated with them, and then executes the operators in a hierarchical order that is defined in the interpreter. In this hierarchy, multiplication comes before addition, and thus 3 is multiplied by 12 first, and then 2 is added.