#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11116620 use warnings; my @excluded = qw( a about although also an and another are as at be been before between but by can do during for from has how however in into is it many may more most etc ); local $/; my %count; $count{$_}++ for split ' ', (lc <>) =~ tr!-'@~,.()?*%/[]="!!dr; delete @count{@excluded}; print "$count{$_} $_\n" for sort { $count{ $b } <=> $count{ $a } || $a cmp $b } keys %count;