use strict; my @end = ( 3, 3, 3 ); my @start = ( 0, 0, 0 ); my @index = @start; LOOP: while (1) { print "this is loop position [ @index ] \n"; for my $q ( reverse 0 .. $#start ) { $index[$q]++; last unless $index[$q] >= $end[$q]; last LOOP unless $q; $index[$q] = $start[$q]; } } print "done \n";
this is loop position [ 0 0 0 ] this is loop position [ 0 0 1 ] this is loop position [ 0 0 2 ] this is loop position [ 0 1 0 ] this is loop position [ 0 1 1 ] ........................... this is loop position [ 2 1 0 ] this is loop position [ 2 1 1 ] this is loop position [ 2 1 2 ] this is loop position [ 2 2 0 ] this is loop position [ 2 2 1 ] this is loop position [ 2 2 2 ] done
In reply to Re: array element as foreach iterator
by fglock
in thread array element as foreach iterator
by kingm61
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |