Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: array element as foreach iterator

by fglock (Vicar)
on Jan 27, 2005 at 20:06 UTC ( [id://425741]=note: print w/replies, xml ) Need Help??


in reply to array element as foreach iterator

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://425741]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found