Why doesn't the first example output a warning?
#!/usr/bin/env perl
use warnings;
use 5.012;
my $c = "9\n";
say $c * 2;
my $d = "6a";
say $d * 2;
# 18
# Argument "6a" isn't numeric in multiplication (*) at ./perl8.pl line 9.
# 12
When converting a number from a string, trailing whitespace is ignored, and newline counts as whitespace, so a warning isn't generated. Converting "9 " doesn't generate a warning either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With