#!/usr/bin/perl my %histogram; while(){ chomp; %histogram{$_}++; } for each (sort keys %histogram){ print "$_ occured $histogram{$_} times.\n"; }