in reply to Re: string increment
in thread string increment
as for the "increment the whole string" comment, you are doing. If you increment the number 4356 to 4357, you only change one 'character', but you are operating on the whole 'string'. This is exactly the same for your example, where only the last character has rolled over, which increments the last but one. If you want to increment each character in the string, you may want to do something like this.
but be careful, incrementing 'z' in this fasion would return 'aa'$sample='prad'; print join('', map { ++$_} split(//, $sample) ); print"$sample";
|
|---|