#!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__ #### (0 0 andy smith 1 john smith )0 (1 0 andy brown 1 john brown )1