#!/usr/bin/perl use strict; use warnings; my ($w, @w, %w); while () { chomp; @w = (0) x 26; $w[$_]++ for map -0x61 + ord lc, /[a-z]/ig; push @{$w{"@w"}}, $_; } print "@$w\n" while (undef, $w) = each %w; __DATA__ opt top pot pit stoop topos pit opt top pot stoop topos