Operators Taken from C Language

This section presents the Perl operators that derive from the C language. Many of these allow for the writing of succinct code.

Assignment Operators

Most operators are binary in nature; that is, they have two operands. For example, the addition operator is binary. In the line of code below, $y and $z are the two operands.

$x = $y + $z;

Any binary operator can be written using the assignment operator rather than using the longer and more traditional approach. Here are some traditional assignment statements using some simple arithmetic operators.

$x = $x + 5;             # addition
$x = $x / 2;             # division
$x = $x * 2;             # multiplication
$x = $x ** 5;            # exponentiation

Perl has a set of operators that are collectively referred ...

Get Programming PERL in the .NET Environment now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.