Think about Loose Coupling | |
PerlMonks |
Re^2: string incrementby davido (Cardinal) |
on Sep 13, 2005 at 07:34 UTC ( [id://491505]=note: print w/replies, xml ) | Need Help?? |
The behavior is not unusual. If you incremented 1111 you would get 1112, and if you incremented it ten times you would get 1121. Eleven times would give you 1122. A hundred times would give you 1211... you get the idea. So, given that alpha characters can also be incremented, it should come as no surprise that they're incremented right to left also; consider the right-most digit to be the least significant digit, whether it's a number or an alpha character. Thus, 'aaaa' would become 'aaab'. Increment it enough times, it it becomes 'aaba', 'aabb', 'aabc' ... 'aaca', 'aacb', 'aacc', and so on, until you finally arrive at 'zzzz'. If you really just wanted to increment each character by one, you might consider constructing a regexp like this:
Dave
In Section
Seekers of Perl Wisdom
|
|