Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The pre-increment and post-increment operators are designed to work on strings too. Witness the following:
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. Dave In reply to Re: Increment avoids warning unexpectedly
by davido
|
|