in reply to Re^4: Permutation with repetitions
in thread Permutation with repetitions

Why loop (4*4*4*(23-2)) times when you can simply loop (23-2) times.
$_ = 'aaaabdbbdaccdacdaaabdcd'; ++$counts{$1} while /(?=([abcd]{4}))/g; print("$_: $counts{$_}\n") for sort keys %counts;

If you want to see the "0" results, you can loop (4*4*4)+(23-2) times.

$_ = 'aaaabdbbdaccdacdaaabdcd'; ++$counts{$1} while /(?=([abcd]{4}))/g; print("$_: $counts{$_}\n") for glob "{a,b,c,d}{a,b,c,d}{a,b,c,d}";