Scalars
-
A variable that holds a single piece of data, similar to variables
in JavaScript.
-
Can be a string or a number. Perl is smart enough to decipher between
the two, and the operators differ.
-
You can assign the results of an operation to a scalar value. For
example:
$result = 5 * 4;
print "The result is $result";
-
The operators are the same ones we used in JavaScript:
addition: +
subtraction: -
multiplication: *
division: /
modulus (remainder): %
exponent: **
-
However, you cannot use + to concatenate strings. We'll get to this
later.
-
The order of operations is: exponents first, then multiplication and division,
then addition and subtraction, left to right.
-
But, if you need to specify your own order, use parenthesis.
-
Example: operators.pl
-
operators.pl Source
More numerical functions
Home