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

For essentially the same reason that ++75 is 76 and not 86:

c:\@Work\Perl\monks>perl -wMstrict -le "my $s = '75'; printf qq{++'$s' -> }; ++$s; print qq{'$s'}; " ++'75' -> '76'
Why would a "carry" ("B" -> "C") be generated by incrementing from "e" to "f"?


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

Replies are listed 'Best First'.
Re^8: How the auto-increment operator works?
by zapdos (Sexton) on Aug 02, 2020 at 01:20 UTC
    Thank you very much. Now I have one more question: why my $foo = "Zz"; print ++$foo; prints "AAa" and not "AAaa"? Since there's two "z" characters and when one "z" character is incremented it produces "aa".
      > > > If a new position is needed it'll adjust to the leftmost group.

      > my $foo = "Zz"; print ++$foo; prints "AAa"

      The A is a new position the next position to the right - which is causing the "carry" - is an uppercase character A.

      > when one "z" character is incremented it produces "aa".

      Again the left a is a new position, and the position to the right is a lowercase character.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        ... I'm not trolling ...

        Hmmm... Starting to question this.


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

        "The A is a new position the next position to the right - which is causing the "carry" - is an uppercase character."

        "Again the left a is a new position, and the position to the right is a lowercase character."

        I don't get either. This is killing me inside. And AnomalousMonk, no, I'm not trolling I swear for God.