in reply to Combinations with variable length

for ( 0 .. 2**$n-1 ) { my @combo = map { $_ + 1 } split //, sprintf("%0*b", $n, $_); say "@combo"; }

use Algorithm::Loops qw( NestedLoops ); my $iter = NestedLoops([ map [ 1, 2 ], 1..$n ]); while ( my @combo = $iter->() ) { say "@combo"; }

Seeking work! You can reach me at ikegami@adaelis.com