September 2017
Beginner
402 pages
9h 52m
English
The + and - operators are operators for addition and subtraction. The operands must be of the numeric type.
There is not much to say about the operators; their behavior is self-explanatory, as follows:
my $a = 10;say $a + 3; # 13my $b = 20;say $b - $a; # 10;
In combination with, for example, * and /, the + and - operators have lower precedence, thus the standard arithmetical rules apply.
When it is possible to cast the string to a number (either integer or floating-point), that conversion will be performed by the compiler, and the + and - operators will work with two numeric operands. Consider the following example:
my $str = "42";say $str - 2; # 40
As the operators expect their arguments to be numeric, ...
Read now
Unlock full access