I wasn't aware of for ( reverse N .. M ) being optimized in *any* case. Because of that, I'd normally write that without the reverse() and use the number as an offset from the end. In the loop, treating the offset as a negative number works to get the "from the end" effect. This buys the iterator space savings of for(N..M) back.
for my $offset ( 0 .. $#ary_a ) { foobar( $ary_a[ -$offset ], $ary_b[ -$offset ] ); }
In reply to Re^2: Looping backwards through two arrays at once?
by diotalevi
in thread Looping backwards through two arrays at once?
by Spidy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |