@x = glob('{a,b,c}'x3); # for testing: all permutations, plus many more $x = '(?:([a-c])(?!.*\1)){3}'; # regex for $i (@x) { $i =~ $x and say $i; # was $x =~ $i }