That's pretty tidy, for sure. It will even work on a
DOS command line. Maybe you'd be interested in shortening what follows?
I worked an absurdly long time on it,
trying to understand
how hashes of arrays work. It borrows heavily from something
by jcwren and from the Cookbook:
perl -e ' use strict; foreach (map {split} map {lc}<>){
push @{ $ARGV[0] {glue => sort split // }}, $_};
foreach (values %{$ARGV[0]}){my %seen=(); my @anagrams=
grep{ ! $seen{$_}++ } @$_ ; print join (" " => @anagrams>1 ?
@anagrams : next ), $/ }'
This doesn't filter out non-alpha stuff, but it does
eliminate duplicates. It's not quite as flexible as yours,
either, but it does take words from STDIN (
- it's too long for in Windows,
but it can be shortened - I'd leave in strict, though.
There's funny stuff going on here that could cause unpredict-
able results if the wrong thing is put on the command-line).
It will also take a redirect from any file (not just lists).
So, it could be used as "perl -e '..etc...' < ${pathto}/wirds
to find anagram in that dictionary (yeesh). No globbing.
Or, it can be invoked as "perl -e '..etc..'__Type Words__
followed by CTRL-D to exit.
I hope it's at least amusing.
mkmcconn |