use strict; use warnings; my (%count, @pcount, @words, @values, $format, $i); my @remove = qw/and the/; # Words to exclude my $width = 10; # Number of words to display $/ = '-100'; # Line delimiter while () { my %pcount; $_ = lc $_; while (m/[a-z]+('[a-z]+)?/g) { next if length($&) < 3; $pcount{$&}++; $count{$&}++; } push @pcount, \%pcount; } for (@remove) { delete $count{$_} if exists $count{$_}; } @words = sort {$count{$b} <=> $count{$a} || $a cmp $b} keys %count; $#words = $width - 1 if $#words > $width - 1; $format = '%' . length($#pcount+1) . 's'; $format .= '%' . (length($_) + 2) . 's' for @words; print ' 'x10, sprintf($format, '', @words), "\n"; for ($i = 0; $i <= $#pcount; $i++) { my @values = $i + 1; push @values, $pcount[$i]{$_} for @words; no warnings; print 'paragraph ', sprintf($format, @values), "\n"; } push @values, $count{$_} for @words; print "\n", ' 'x10, sprintf($format, '', @words), "\n"; print ' 'x10, sprintf($format, '', @values), "\n"; __DATA__ So it was into a neighborhood bursting with rumors and resentment that Gopi, the ten year old cousin who had been brought down from the village to be the household help, stepped out to do his daily chores. His responsibilities included:-100 1. Carrying the copper tray for the old lady and trotting behind her at the proper pace when she went out to do her morning prayers at five am in the morning.-100 2. Bringing the wood, the coal, and the kindling so that the daughter-in-law could light the fire.-100 3. Bringing water from the well to the fifth floor, where the kitchen was located.-100 4. Cutting the vegetables, cleaning the rice, soaking the lentils, shelling the peas and any other sundry time-consuming tasks that arose in a kitchen with a mortar and pestle and precious little else.-100