- Perl ›
- Operators ›
- Arithmetic operator ›
- here
Subtraction operator " - " - Numeric subtraction
You can use the subtraction operator "-" to subtract numbers.
my $num3 = $num1-$num2;
This is an example that subtracts 5 from 3.
my $total = 3-5;
In Perl, even a small number of subtractions can be done without being aware of the type.
my $total = 3.5 - 2.7;
Explanation of arithmetic operators
The subtraction operator is one of the arithmetic operators. For a detailed explanation of arithmetic operators, see the Arithmetic Operators Explanation page.