my @letters = qw(d u n s c a e y t); open(D,"/usr/dict/words") or die $!; my @words = f(@letters); print "$_\n" for @words; sub f { # 1 2 3 4 5 6 #234567890123456789012345678901234567890123456789012345678901234 $;=join'?',sort@_,$;;grep{chop;(join'',sort split//)=~/^$;$/} } __END__ =head1 SAMPLE OUTPUT ace aces acne act acted acute ad ads an and [SNIP] uneasy unsteady [SNIP] #### # 1 2 3 4 5 6 7 #234567890123456789012345678901234567890123456789012345678901234567890123456 $,=join'?',sort(@_),'';grep{chop;$;=join'',(sort(split//,$_));$;=~/^$,$/} $,=join'?',sort(@_),'';grep{chop;(join'',(sort(split//,$_)))=~/^$,$/} $,=join'?',sort(@_),'';grep{chop;(join'',sort split//)=~/^$,$/} $;=join'?',sort@_,$;;grep{chop;(join'',sort split//)=~/^$;$/} # with japhy's help... $;=join'?',sort@_;grep{chop;(join'',sort split//)=~/^$;?$/} @_=sort@_;$"='?';grep{chop;(join'',sort split//)=~/^@_?$/} # with dragonchild's help, and a 'perl -l' trick: @_=sort@_;$"='?';grep{(join'',sort split//)=~/^$\@_?$/} # stealing a bit from gbarr @_=sort@_;$"='?';grep{(join'',sort/./g)=~/^@_?$/}