Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How the auto-increment operator works?

by jcb (Parson)
on Jul 31, 2020 at 01:57 UTC ( [id://11120106]=note: print w/replies, xml ) Need Help??


in reply to How the auto-increment operator works?

Think of it as counting in a weird base-26: 99++ —> 100, Ay++ —> Az, Az++ —> Ba, so zz++ —> aaa.

  • Comment on Re: How the auto-increment operator works?

Replies are listed 'Best First'.
Re^2: How the auto-increment operator works?
by zapdos (Sexton) on Aug 01, 2020 at 18:50 UTC
    I don't get it. Can you explain more thoroughly please?

      When you are counting in base-10 and you reach 99, you add a leading "1" instead of wrapping back to only "00". The magic autoincrement does the same with letters: when you reach the end of the alphabet, it adds a leading "a" while wrapping back instead of repeating a previous value.

      This is also why "z" becomes "aa":

      $ perl -e '$X = "z"; print $X, "\n"; $X++; print $X, "\n";'
      z
      aa
      
        Thank you ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11120106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found