#!/usr/local/bin/perl my %w; my $fn = shift; open my $fh, '<', $fn; while(<$fh>) { chomp; $w{lc($_)}++ foreach(split /\s+/); } print $w{$_},"\t",$_,"\n" foreach(sort { $w{$b} <=> $w{$a} or $a cmp $b } keys %w);