perl -E 'say "match" if 0.0 =~ m/^\d+/'
This matches. But "." is not included in \d, so why does it match? Because 0.0 is a number that gets implicitly stringified for the purpose of binding to a pattern match. The rules of numeric stringification are to evaluate the numeric value and convert that numeric value to a string representation. Try this, to see it at work:
perl -E 'my @match = 0.0 =~ m/^(\d+)$/; say "@match";'
The output will be "0", demonstrating that the value is what gets stringified, not the source code you typed into the keyboard to create the value.
When you wrap the 0.0 in quotes first, you create a string, "0.0", which is taken exactly as it is, for the purpose being bound to a pattern match.
On the other hand, the value 0.5 stringifies as "0.5", preserving the decimal point in the process. The decimal doesn't match \d, so the match fails.
|