#!/usr/bin/perl -wl use strict; my $min = 3; my %words; while (<>) { chomp; next unless length > $min; my $index = lc $_; $index =~ tr[abc def ghi jkl mno pqrs tuv wxyz] [222 333 444 555 666 7777 888 9999]; push @{$words{$index}}, $_; } for my $index (sort {$a <=> $b} keys %words) { my @words = sort @{$words{$index}}; next unless @words > 1; print for '', @words; } __END__