in reply to Creating tuples based on sets

One more variation ;-)

CPAN provides us with Set::CrossProduct, which allows us to write your mk_tuples like this:

use Set::CrossProduct; sub mk_tuples(\@$) { my ($arrayref, $n) = @_; [ Set::CrossProduct->new( [($arrayref) x $n] )->combinations ]; }; my @set = qw(A B C); my $output = mk_tuples(@set, 2);