Re: loop counting

2001-06-29 Thread Bob Mangold
Paul, Within the loop, some other programs are executed and occasionally it may take a few minutes to complete everything and then continue. So I'm just throwing a little counter to STDOUT so I can monitor the progress, to ensure it doesn't get hung up somewhere. I knew of all the different ways

Re: loop counting

2001-06-29 Thread Paul
--- Bob Mangold <[EMAIL PROTECTED]> wrote: > Is there a perl variable that automatically counts loop iterations. > Such that I don't have to use '$count': > > foreach (@array){ > $count++; > ..whatever.. > } Lot's of people with suggestions, but I have a question -- what are you using $coun

RE: loop counting

2001-06-29 Thread Kipp, James
if your looping thru the elements of an array you can always just grab the # of elements: $elem = scalar(@array); > > Is there a perl variable that automatically counts loop > iterations. Such that I > > don't have to use '$count': > > > > foreach (@array){ > > $count++; > > ..whatever..

Re: loop counting

2001-06-29 Thread Michael Fowler
On Fri, Jun 29, 2001 at 02:58:20PM -0400, Jeff 'japhy' Pinyan wrote: > No there is not. Either do: > > my $i = 0; > for (@foo) { > # ... > } > continue { $i++ } > > or do: > > for my $i (0 .. $#foo) { > my $element = $foo[$i]; > # ... > } or for (my $i = 0; $i < @

Re: loop counting

2001-06-29 Thread Brett W. McCoy
On Fri, 29 Jun 2001, Bob Mangold wrote: > Is there a perl variable that automatically counts loop iterations. Such that I > don't have to use '$count': > > foreach (@array){ > $count++; > ..whatever.. > } You can always do, if you need a loop variable: foreach my $i (0..$#array) {

Re: loop counting

2001-06-29 Thread Jeff 'japhy' Pinyan
On Jun 29, Bob Mangold said: >Is there a perl variable that automatically counts loop iterations. Such that I >don't have to use '$count': No there is not. Either do: my $i = 0; for (@foo) { # ... } continue { $i++ } or do: for my $i (0 .. $#foo) { my $element = $foo[$i];