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


In reply to Re: Anagram Finder by mkmcconn
in thread Anagram Solver by kilinrax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.