http://qs321.pair.com?node_id=11120227


in reply to Re^10: How the auto-increment operator works?
in thread How the auto-increment operator works?

Perhaps the best thing to do is to remember that in "magic" string incrementation, digit/lowercase/uppercase characters increment from right to left, wrap within themselves, and generate a "carry" into the next left column (or a new left column character if it's already the leftmost (update: and see LanX's reply concerning the "type" of a new column)) when they wrap:

increment left col ("carry") <- '0' -> '1' -> .. '9' (digits) ^ | | | +----------------+ increment left col ("carry") <- 'a' -> 'b' -> .. 'z' (lower case) ^ | | | +----------------+ increment left col ("carry") <- 'A' -> 'B' -> .. 'Z' (upper case) ^ | | | +----------------+
String incrementation is pretty stable. I've never known it to change and I doubt it ever will (to preserve backward compatibility), so the best thing I can suggest is to experiment. Whatever results you get are the way "magic" string incrementation works.
c:\@Work\Perl\monks>perl -e "my $s = 'zZ9'; print qq{'$s' -> }; ++$s +; print qq{'$s'};" 'zZ9' -> 'aaA0' c:\@Work\Perl\monks>perl -e "my $s = 'Zz9'; print qq{'$s' -> }; ++$s +; print qq{'$s'};" 'Zz9' -> 'AAa0' c:\@Work\Perl\monks>perl -e "my $s = 'Zzzz9'; print qq{'$s' -> }; ++ +$s; print qq{'$s'};" 'Zzzz9' -> 'AAaaa0' c:\@Work\Perl\monks>perl -e "my $s = 'zzzz9'; print qq{'$s' -> }; ++ +$s; print qq{'$s'};" 'zzzz9' -> 'aaaaa0' c:\@Work\Perl\monks>perl -e "my $s = 'ZZZZ9'; print qq{'$s' -> }; ++ +$s; print qq{'$s'};" 'ZZZZ9' -> 'AAAAA0'


Give a man a fish:  <%-{-{-{-<