No. You didn't assign the results of $a + 3 back to $a, so I don't know what you would have expected it to do. The results I would expect would be 3
IMHO, ab11 is more reasonable.
This is documented in perlop (search for "Auto-increment"). The critical portion is:
the increment is done as a string, preserving each character within its range, with carry [emphasis added]If it were implemented the way you propose, then the with carry part would no longer be valid. Since you are able to just do a string append of a numeric value to implement your use case ($base . $counter++), and it becomes much more difficult to do the string carry use case, IMHO it makes much more since to implement the string increment magic* as it currently stands.
* I am not arguing for, or against, the string magic increment here, as I have not given enough thought to make an argument considering both sides. However, I can point to cases where I have used it in the past.
--MidLifeXis
In reply to Re: string operations of arithmetic
by MidLifeXis
in thread string operations of arithmetic
by xiaoyafeng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |