in reply to Multiplexing array of arrays?

use Algorithm::Loops qw( NestedLoops ); my @spec = ( [ 'static1' ], [ 'ar1', 'ar2' ], [ 'static2' ], [ 'ar3', 'ar4', 'ar5' ], ); NestedLoops(\@spec, sub { print(join(', ', @_), "\n"); });

Or closer to what you have:

use Algorithm::Loops qw( NestedLoops ); my @spec = map { ref($_) ? $_ : [$_] } ( 'static1', [ 'ar1', 'ar2' ], 'static2', [ 'ar3', 'ar4', 'ar5' ], ); NestedLoops(\@spec, sub { print(join(', ', @_), "\n"); });

Update: Fixed bug.
Update: Added alt.