in reply to What Happened...(perils of porting from c)

Here is a native Perlish thing that basically does what I think you really want. Note how much shorter this is than the C version.
use strict; nested_for( sub {print "@_\n";}, [1..2], ['a'..'c'], ['A'..'D'] ); sub nested_for { ret_iter(@_)->(); } sub ret_iter { my $fn = shift; my $range = shift; my $sub = sub {$fn->($_, @_) for @$range}; return @_ ? ret_iter($sub, @_) : $sub; }
Also note the lack of pointer arithmetic to mess up on. :-)