I have looked at the posts on the site, as well as the Algorithm::Permute module, but nothing seems to correctly match my problem. Everything I have seen is in regards to getting N Permutations of N items. My problem requires that I get N Permutations of M items. Here's what I'm doing:

I'm taking a list of letters and finding matches in the dictionary that contain a permutation of these letters. I have gotten to the point where if I pass it the string "ciolnaot", it will find 'location'. This is being done with the above-mentioned Algorithm::Permute. This is working fine, but now I need to add a new twist to it. I want to specify the length of the words the script will find in the dictionary. Meaning that if I specify the string "ciolnaot" and a length of 4, I want to find 'coal', 'colt', 'loin', 'lion', 'toil', and whatever other 4-letter words exist in there, and only the words of that length.

So rather than taking the string, splitting it and finding permutations of it, it seems it becomes more complicated as I think I'll need to get 4-character permutations from the original string of letters, and then permutate each of those permutations... Am I making sense anymore? :)

One thing I hope I may be missing is another module like Algorithm::Permute that is more advanced, in allowing permutation string lengths or something similar. Please help!

-------------------------------------
eval reverse@{[lreP
=>q{ tsuJ\{qq},' rehtonA'
,q{\}rekcaH },' tnirp']}[1+1+
1,1-1,1+1,1*1,(1+1)*(1+1)];
-------------------------------------

In reply to N Permutations of M Items by mt2k

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.