use strict;
use warnings;
my %in_hash;
while (<DATA>) {
chomp;
my ($type, $value) = split /,/;
$in_hash{$type}{count}++;
$in_hash{$type}{value} += $value;
}
while (my($type, $data) = each %in_hash) {
print $type, " ", $data->{value}/$data->{count}, "\n";
}
__DATA__
red,5
red,10
red,0
blue,6
blue,1
blue,2