[prev] [index] [next]

Scalars (cont)

A very common pattern for modifying scalars is:

$var = $var op expression

Compound assignments for the most common operators allow you to write

$var op= expression

Examples:

$x += 1;     # increment the value of $x
$y *= 2;     # double the value of $y
$a .= "abc"  # append "abc" to $a