in reply to array and counting
my @gene = split //, $seq[$i]; my $count = @gene; if($i < $#seq) { push @gene, split //, substr $seq[$i+1], 0, 3; } # Now, proceed as before: for (my $i=0; $i<$count; $i+=3) { ... }
p.s. You don't actually need to split the strings into arrays, a plain proper use of substr will work just as fine, as in:
substr($genestring, $i, 1)
|
|---|