How do I implement a cyclic array in perl

2011-11-28 Thread Ramprasad Prasad
I have an array of scalars. I want to run a loop like this my @workers = qw ( a b c ); my $MAXCHILD = 20; foreach my $i( 0 .. $MAXCHILD){ run_job($i,$workers[$i++]); } Can I do this ?

Re: How do I implement a cyclic array in perl

2011-11-28 Thread Shawn H Corey
On 11-11-28 10:03 AM, Ramprasad Prasad wrote: I have an array of scalars. I want to run a loop like this my @workers = qw ( a b c ); my $MAXCHILD = 20; foreach my $i( 0 .. $MAXCHILD){ run_job($i,$workers[$i++]); } Can I do this ? for my $i ( 0 .. $MAXCHILD ){ run_job( $i,

Re: How do I implement a cyclic array in perl

2011-11-28 Thread Rob Dixon
On 28/11/2011 15:03, Ramprasad Prasad wrote: I have an array of scalars. I want to run a loop like this my @workers = qw ( a b c ); my $MAXCHILD = 20; foreach my $i( 0 .. $MAXCHILD){ run_job($i,$workers[$i++]); } Can I do this ? Take a look at Array::Iterator, which has an