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