pchou has asked for the wisdom of the Perl Monks concerning the following question:
I have some code that does it using a for loop, but I wanted to get it to work using "grep". I thought it would be cleaner and nicer. This doesn't work, though I have been trying very hard to find my mistake but I have been unlucky so far:% anagram_finder.pl elloh hello %
Any help would be greatly appreciated.open DICT, "</usr/dict/words" or die "no more words: $!"; $a = join "", sort split "", lc shift; print join "\n", grep {$a eq join "", sort split "", lc} <DICT>;
Paul Chou
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Anagram finder
by jeroenes (Priest) on Apr 24, 2001 at 09:43 UTC | |
by pchou (Novice) on Apr 24, 2001 at 22:12 UTC | |
|
Re (tilly) 1: Anagram finder
by tilly (Archbishop) on Apr 24, 2001 at 09:40 UTC | |
|
Re: Anagram finder
by frankus (Priest) on Apr 24, 2001 at 19:15 UTC |