Perlaccess : Tutorials : Operators
Operators: Assignment (6.2)
by Brett Roberts
http://www.bigresources.com

Assignment Operators
Assignment Operators do exactly what their name suggests, they assign values. The most common occurence of an assignment operator is when you initialize your variables. The following table outlines the different assignment operators used widely in perl scripts, note: these are used in conjunction with our arithmetic operators in lesson (6.1):

= Normal assignment of values
+= Add then Assign value
-= Subtract then Assign value
*= Multiply then Assign value
/= Divide then Assign value
**= Exponent then Assign value
%= Modulus then Assign value


The above operators often are used to save typing the longer versions of the same assignment which can ultimately decrease the amount of code in your script... below is some sample code to get your feet wet:

# This calculation will find total web page visits for 1
# year assuming we know each months' visits
# Note: this same example used in our arithmetic
# operators tutorial can also be used to demonstrate
# our assignment operators...the initialization of the
# month variables below are using the normal
# assignment operator mentioned above...

$january=345;
$february=256;
$march=444;
$april=541;
$may=678;
$june=350;
$july=411;
$august=398;
$september=500;
$october=758;
$november=648;
$december=1555;


# To be safe...it would be wise to place the following
# statement all on 1 line in your code...

$total_visits=$january+$february+$march+$april+
                   $may+$june+$july+$august+$september+
                   $october+$november+$december;