#!/usr/bin/perl while(<>) { chomp $_; map {$hash{$_}++ => $_} $_; } map {print ("$hash{$_}: $_\n") => $_ } sort keys %hash;