my %hash; while () { chomp; $hash{$_} ++; } $\ = "\n"; while (my ($k, $v) = each %map) { print $k, $v; }