in reply to Re: POE - can't increment within sub
in thread POE - can't increment within sub
... as explained in perlop#Auto-increment-and-Auto-decrement:
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:print ++($foo = "99"); # prints "100" print ++($foo = "a0"); # prints "a1" print ++($foo = "Az"); # prints "Ba" print ++($foo = "zz"); # prints "aaa"
Cf. First JAPH - Spell perl in two hundred and eighty five thousand and seventy four easy steps. ;-)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: POE - can't increment within sub
by ljamison (Sexton) on Dec 12, 2015 at 04:50 UTC | |
by Anonymous Monk on Dec 12, 2015 at 06:03 UTC | |
by ljamison (Sexton) on Dec 12, 2015 at 15:05 UTC | |
|
Re^3: POE - can't increment within sub
by Anonymous Monk on Dec 12, 2015 at 06:01 UTC | |
|
Re^3: POE - can't increment within sub
by ljamison (Sexton) on Dec 13, 2015 at 02:44 UTC | |
by Athanasius (Archbishop) on Dec 13, 2015 at 04:10 UTC | |
by AnomalousMonk (Archbishop) on Dec 13, 2015 at 04:11 UTC | |
by Athanasius (Archbishop) on Dec 13, 2015 at 04:27 UTC |