Contents Up Previous Next

3.1 Operators and Precendence

Here are some perl operators of interest.

+,-,*,/

Respectively adds, subtracts, multiplies and divides two floating point numbers.

a ** b

Raises a to the power of b. Works on floating point numbers too.

a . b

Concatenates two strings. The comma (,) as used by print does not really concatenates two strings, but rather prints them one after the other. (There's a subtle difference in functionality of the print command too, but I won't get into that, now).

print "Hello," . " " . "World!" . "\n" .
    "And this is the second line.\n";

a % b

Returns the modulo (reminder) of b from a. If a and b are not integers they are rounded to an integral value.

( sub-expr )

Makes sure that sub-expr is evaluated as a separate sub-expression , an operation that could override the defualt operator precendence.


There are many more, but they will be covered later. For a complete list and more detailed information about the various perl operators consult the "perlop" man page on your system.


Contents Up Previous Next