#!/usr/bin/perl use strict; use warnings; my %sum; my %count; for my $row () { chomp($row); my ($string, $zahl) = split /\s+/, $row; $sum{$string} += $zahl; $count{$string} ++; } for my $string (sort keys %sum) { my $mittelwert = $sum{$string}/$count{$string}; print "$string: $mittelwert\n"; } __DATA__ foo 40 bar 41 baz 43 foo 44