On Fri, Jan 28, 2011 at 4:00 AM, Abigail <abigail@abigail.be> wrote: > > | The auto-increment operator has a little extra builtin magic to > > | it. If you increment a variable that is numeric, or that has > > | ever been used in a numeric context, you get a normal increment. > > | If, however, the variable has been used in only string contexts > > | since it was set, and has a value that is not the empty string > > | and matches the pattern "/^[a-zA-Z]*[0-9]*\z/", the increment is > > | done as a string, preserving each character within its range, > > | with carry: > > > > (From perlop.pod; note the phrase "used in a numeric context") > > Note that the documentation the quote contains a couple of white lies. > > $a = "foo123"; > 0 + $a; # Use the variable $a in numeric context > $b = $a; > $a = "bar456"; > $a ++; > $b ++; > say $a; # Prints 'bar457'; > say $b; # Prints '1'; > > > So, we have a variable $a that's used in numeric context, and variable > $b that isn't, yet $a gets the magic autoincrement, but $b doesn't. > The mistake is talking about the variable instead of the value. I think it can be fixed by changing If you increment a variable that is numeric, or that has ever been used in a numeric context, to If you increment a value that is numeric or has ever been used in a numeric context, - EricThread Previous | Thread Next