my $ia = 0 ; foreach my $a (@afoo) { ... acres of stuff ... $ia++ ; } ;