use Algorithm::Loops qw( NestedLoops ); splice(@aoa, $count); NestedLoops(\@aoa, sub { print(@_); });