Try the following example:
print 0..9,"\n";
You get 0123456789. Now try the following code:
print 9..0,"\n";
You don't get much of anything at all. Camel says, "The range operator (in a list context) makes use of the magical autoincrement algorithm if the operands are strings."
What isn't stated, but perhaps can be deduced, is that the range operator internally uses the autoincrement function, which when fed strings, behaves magically, and when fed numbers behaves normally. But the point is, the range operators don't use the autodecrement function.
It seems to me (and this is pure speculation) that the autoincrement operator was given its special magic so that the range operator can construct things like A..Z. Again, this is speculation, but .. needed to be able to handle A..Z, .. internally used the autoincrement function, so to make it easy, autoincrement was given magic so that the range operator could become a more useful operator, not limited only to numbers.
Now as for why the range operator doesn't enumerate descending-value lists also, that's another question, and I shouldn't speculate. ;)
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
In reply to Re: Re: $a++ allowed by $a-- is not ! why?
by davido
in thread $a++ allowed by $a-- is not ! why?
by abhishes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |