Maybe you want Algorithm::Loops::NextPermute ? You can give it lists of lists of characters and it will spit out strings (well, lists) of the combinations:
my @characters = (qw(C N N N N N ));
my @list= sort ;
do {
usePermutation( @list );
} while( NextPermute( @list ) );
... or maybe the NestedLoops function is more it - I'm not sure if you also want to generate strings with 2C 4N and so on, and what other characters come into play.
If there are only two characters coming into play, generating all permutations is equivalent to counting from 1..2**$number_of_characters_in_target_string and interpreting that number as binary, a 1 is "use that character" and a 0 means "use the other character".