good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Why does $string++ work the way it does?by davido (Cardinal) |
on Sep 14, 2003 at 03:18 UTC ( [id://291339]=note: print w/replies, xml ) | Need Help?? |
The ++ operator can act upon both numbers and strings in a predictable fashion. With strings, 'A' increments to 'B', and 'Z' to 'AA'. ...and so on.
The magic of the ++ operator with respect to strings also exherts itself by providing the .. operator (range operator) with similar magic. Try this at home...
It seems that ++ magic, and .. magic, are related. Don't be fooled into expecting -- to be magic too though, it isn't. Neither can you use the .. operator alone to create descending lists.
Have fun with ++ and .. but take care not to expect magic from --. -- is for numbers.
In Section
Seekers of Perl Wisdom
|
|