use Algorithm::Loops qw( NestedLoops ); my @ps = map { $_ * 0.2 } 0..5; my $iter = NestedLoops([ (\@ps) x 11 ]); while (my @p = $iter->()) { my $temp_out = join("\t", @p, 1, 1)."\n"; ... }