my @words = do { open my $fh, "<", "/usr/dict/words" or die; <$fh>; }; chomp @words; sub normalize { join "", sort split //, $_[0]; } my %dict; push @{ $dict{normalize($_)} }, $_ for @words; #### abd => ["bad", "dab"], aepr => ["pear", "reap", "rape"] ...