#!perl -nl END{print"$_ ($w{$_})"for sort keys%w;print"\n$t"}s/\b(\w+)\b/$w{$1}++;$t++/eg