in reply to Finding elements without a counter...

I'm not to clear on what you're trying to do, but here are some things to consider... Since the third column, corresponding to the $letter1 variable seems to remain a single character, and you don't seem to be doing anything more with it than counting it, try this technique instead. I'm unclear as to how you want to scan your @prettybase array, but you might want to consider making the processing of an input record into a subroutine like this:
## ## Will process the records between $start and $end ## and count the occurances of the third ## field, returning the total count and a ## has containing the individual counts keyed ## by the letter. ## sub processRec { my($arrayRef, $start, $end) = @_ ; my($i, $total, $letter_counts) ; my($position, $patient, $letter1, $letter2) ; for( $i = $start ; $i <= $end ; $i++ ) { ($position, $patient, $letter1, $letter2)=split(/\t/, $arrayRef->[ +$i]); $letter_counts->{uc $letter1} += 1 ; } $total = 0 ; for( values %$letter_counts ) { $total += $_ ; } # for return($total, $letter_counts) ; } @prettybase = map chomp, <INPUT> ; # # do something to determine start and stop points # ($total, $counts) = processRec(\@prettybase, start, end) ; while( ($letter, $count) = each %$counts ) { print "$letter => ", ($count*100)/$total, "\n" ; }
You may want to consider 'pre-splitting' the @prettybase array into an array of array refs just so you don't have to keep resplitting the lines. This would be good if your input files are huge, and you're going back and forth over it many times.