while(<>) {
  foreach $word (split) {
    $score{$word}++;
  }
}

foreach $word (sort keys %score) {
  print "$word $score{$word}\n";
}
