Perl;如何避免严重嵌套的foreach循环

我想循环显示12个字符串,并列出它们的每种组合,例如,我将工作代码缩短了3个术语:

foreach my $t1 ('a', 0) {
    foreach my $t2 ('b', 0) {
        foreach my $t3 ('c', 0) {
            my @terms = grep {$_ ne '0'} ($t1, $t2, $t3);
            say join ('+', @terms);
        }
    }
}

哪个输出

a+b+c
a+b
a+c
a
b+c
b
c

这是正确的输出。

However, I realize that deep nesting of foreach loops isn't good coding practice.

I have looked at alternatives to this in Alternate looping nested foreach loops but this requires this is also really ugly:

my @t1 = ("a", (0) x 132);
my @t2 = ("b", (0) x 132);
my @t3 = ("c", (0) x 132);
my @t4 = ("d", (0) x 132);
my @t5 = ("e", (0) x 132);
my @t6 = ("f", (0) x 132);
my @t7 = ("g", (0) x 132);
my @t8 = ("h", (0) x 132);
my @t9 = ("i", (0) x 132);
my @t10 = ("j", (0) x 132);
my @t11 = ("k", (0) x 132);
my @t12 = ("l", (0) x 132);

my $it = each_array(@t1, @t2, @t3, @t4, @t5, @t6, @t7, @t8, @t9, @t10, @t11, @t12);
while (my ($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $t12) = $it->()) {
    my @terms = grep {$_ ne '0'} ($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $t12);
    say join ('+', @terms);
}

this just outputs blank spaces, and doesn't seem to do what I think each_array is supposed to do. I'm not even sure that there will be 132 iterations.

如何在不深入嵌套foreach循环的情况下完成这12个术语?