use strict; use warnings; my %level = ( A=>3, T=>2, G=>2, C=>1 ); my $string = "ATATGCGCAT"; my $n = 1; $n *= $level{$_} for( split '', $string ); print "Number of combinations: $n\n"; $string =~ s/(.)/$1."{".join(",",1..$level{$1})."}"/ge; print "~$_\n" while(< $string >);