http://qs321.pair.com?node_id=624052

jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

monks,

Apologies if this has been discussed already.

my $iteration_number = 1; foreach my $val ( @array ) { print ":$iteration_number:\n"; $iteration_number ++; }
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.