in reply to the '..' operator and decreasing values

.. always counts up. I don't know why, but this workaround will do the trick:

for ( 0 .. 10 ) { my $i = 10 - $_; # do something }

Replies are listed 'Best First'.
Re^2: the '..' operator and decreasing values
by merlyn (Sage) on Mar 04, 2005 at 22:31 UTC

      Let's hope the list isn't too long. for (0..x) is evaluated lazily, but I doubt that for (reverse x..0) is as well.

      On second thought, that would rarely matter.

      Does this create a list all at once so that it can reverse it as opposed ikegami's solution which creates only one value at a time? I ask because I honestly don't know.

      Update: Yarr...that's what I get for not refreshing.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come