- Numeric operations apply a numeric context
- Undefined values are treated as zero
- Scalars are evaluated as numbers
- Strings are converted to their numeric value automatically
- Non-number strings are converted to zero
- Arrays are evaluated as their length
my $number;
my $string; # Zero in numeric context
$number = $string + 17;
print "Number is $number.\n";
$string = "5.2"; # 5.2 in numeric context
$number = $string + 17;
print "Number is $number.\n";
$string = "five"; # Zero in numeric context
$number = $string + 17;
print "Number is $number.\n";
Number is 17.
Number is 22.2.
Number is 17.
|