for my $penta (keys %totalProbability) { print "$totalProbability{$penta}, $totalCounts{$penta}, ...\n"; } #### my %stats; while () { chomp; my ($pent, $pentExpected, $pentObserved, $pentTotal) = split("\t", $_); next if !defined $pentTotal; # skip malformed lines and end line my $h = { pent=>$pent, count=>$pentObserved, prob=>$pentExpected, pentTotal=>$pentTotal }; push @data,$h; if (exists $stats{$pent}) { $stats{$pent} = { probTotal => $$h{prob}, countTotal => $$h{count}, pentTotal => $$h{pentTotal}, }; } else { $stats{$pent}{probTotal} += $$h{prob}; $stats{$pent}{countTotal} += $$h{count}; $stats{$pent}{pentTotal} += $$h{pentTotal}; } }