foreach $prot_string (@truncated_sequences) { foreach $tri_seq (@triamino_combo) { $tri_freq{$tri_seq} = 0; while ($prot_string =~ /$tri_seq/g) { $tri_freq{$tri_seq}++; } } }