I have an array reference like below:
my $strings = [qw(a b c d)];
I want to form all possible combination and create an array of array as:
my $output = [qw(qw([a],[b],[c],[d],[a,b],[a,c],[a,d],[b,c],[b,d],[c,d], [a,b,c],[a,b,d],[b,c,d],[a,b,c,d]))]
What I tried:
foreach my $n(1..scalar(@array)) {
my $iter = combinations($strings, $n);
while (my $c = $iter->next) {
print "@$c\n";
}
}