in reply to Automatic Loop Counter not in perl

There's no need for a special variable for you can implement this perfectly well in perl.

#!perl use warnings; use strict; our $LOOPCOUNTER; sub forc (&@) { my($func, @arr) = @_; for $LOOPCOUNTER (0 .. @arr - 1) { &$func(local $_ = $arr[$LOOPCOUNTER]); } } forc { my($last) = @_; print "($LOOPCOUNTER\n"; forc { print " $LOOPCOUNTER $_ $last\n"; } qw"andy john"; print ")$LOOPCOUNTER\n" } qw"smith brown"; __END__

Output:

(0 0 andy smith 1 john smith )0 (1 0 andy brown 1 john brown )1

(Update: yeah, I didn't read the replies again. Roy Johnson has already said the same thing.)