## ## 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, ; # # 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" ; }