Arrays

A slight diversion - binary assignment operators

Note:

A short hand for

$k = $k - 2;

is

$k -= 2;

Similarly, you may use:

$k += 2;    # same as $k = $k + 2;
$k *= 2;    # same as $k = $k * 2;
$k /= 2;    # same as $k = $k / 2;

or even:

$k .= "some string";    # same as $k = $k . "some string";

These are called binary assignment operators, and are very useful in iterative (looping) constructs.


Table of Contents.
Previous | Next.