Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
prints out 'a' to 'z', and then 'aa', 'ab', to 'az'. How does this work? (1) it looks like it's doing character arithmetic, but why stopps at 'z'? (2) if I change first line to $a='A', it will do the same iteration only with capital letters, why not iterate through all ascii? (3) if I replace $a++ by $a = $a+1, then it prints 1,2,..10. What's the different between increments and assignment here?$a = 'a'; while(length($a) < 3) { print $a++, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange character arithemtic
by toolic (Bishop) on Jan 19, 2014 at 23:16 UTC | |
|
Re: Strange character arithemtic
by choroba (Cardinal) on Jan 19, 2014 at 23:19 UTC | |
|
Re: Strange character arithemtic
by AnomalousMonk (Archbishop) on Jan 19, 2014 at 23:27 UTC |