This has already been addressed, but I think the simplest solution is just to handle your special case in custom code and then rely on the standard modules for everything else.
For combinatoric modules, can use either Algorithm::Combinatorics
or Math::Combinatorics
.
use strict;
use warnings;
use Algorithm::Combinatorics qw(variations_with_repetition);
use List::MoreUtils qw(uniq);
my @set = ('A'..'C');
my $length = 3;
# Trivial Diagonal Solutions
for my $element (@set) {
my @solution = ($element) x $length;
print "@solution\n"
}
# All Other Solutions
my $iter = variations_with_repetition(\@set, $length);
while (my $p = $iter->next) {
next if 1 == uniq @$p;
print "@$p\n"
}