Given how "++" is, in a sense, intrinsically overloaded, and given Perl's intrinsic flexibility about interpreting the "data type" (string? int? float?) of a scalar value, I would be hesitant to ask for whole lot of special condition checks on this operator, for fear of slowing down all the scripts that use it so often. There's only a limited amount of idiot-proofing that the language can do for you and still be deemed suitable for effective use.
Even when strings do "meet the conditions", it's still no guarantee that you're going to end up with what you intended:
I agree with the view expressed below: the current behavior is consistent, in a way that makes sense, with other related behaviors. (++Fletch ! ... or should I say "Fletci !") (updated for grammar correction)$ perl -le '$x="12345678901234567890"; print $x; ++$x; print $x' 12345678901234567890 12345678901234567891 $ perl -e '$x="12345678901234567890";printf "%20.0f\n",$x; ++$x;printf + "%20.0f\n",$x' 12345678901234567168 12345678901234567168 # or, just as bad: $ perl -le '$x="12345678901234567890"; printf "%20.0f\n",$x; ++$x; pri +nt $x' 12345678901234567168 1.23456789012346e+19
In reply to Re^2: String increment - reasoning
by graff
in thread String increment - reasoning
by throop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |