jesuashok has asked for the wisdom of the Perl Monks concerning the following question:
Apologies if this has been discussed already.
In the above code to get the iteration number I am using a explicit flag to get the iteration count. I am interested to know, is there any built-in variable available to hold the iteration count ? For example $. holds the line number during the any FILEHANDLING operation.my $iteration_number = 1; foreach my $val ( @array ) { print ":$iteration_number:\n"; $iteration_number ++; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: getting iteration number inside iteration loop
by blazar (Canon) on Jun 29, 2007 at 07:36 UTC | |
by jesuashok (Curate) on Jun 29, 2007 at 08:12 UTC | |
Re: getting iteration number inside iteration loop
by GrandFather (Saint) on Jun 29, 2007 at 07:34 UTC | |
Re: getting iteration number inside iteration loop
by ikegami (Patriarch) on Jun 29, 2007 at 13:19 UTC | |
Re: getting iteration number inside iteration loop
by ferreira (Chaplain) on Jun 29, 2007 at 14:47 UTC |