The pre-increment and post-increment operators are designed to work on strings too. Witness the following:
my $string = "abc";
print ++$string, "\n";
If my calculations are correct, you should see "abd".
So the point is that if you give ++ a string that it can figure out, it will increment it. Thus, non-numeric strings are legal arguments for ++. Now, in your case, you gave the increment operator a string that it couldn't sensibly increment in its non-numeric form, so the ++ operator dropped into numeric form, and incremented 0 to 1. No warning because non-numeric strings are legal in this case.
To read more about the ++ operator's "magic", see perlop.
|