Hi.

Thank you for your help. With your code there, it appears it does exactly what I needed. But when I changed it to read in my partial dictionary file, it started to throw out words that it couldn't have matched.

#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; print header, start_html(); my $letters = 'balphe_'; my (%lhash, @solutions, $blanks, $bcopy, $l); $blanks++ while $letters =~ s/[^a-z]//; $lhash{$_}++ for split //, $letters; open (DICT, "dict/dict1.txt") or die "error :!"; while (<DICT>) { $bcopy = $blanks; my %whash; chomp; $whash{$_}++ for split //; for $l (keys %whash) { no warnings; last if $lhash{$l} < $whash{$l} && ($bcopy -= $whash{$l} - $lhash{$l}) < 0; } push @solutions, $_ if $bcopy > -1; } print join "\n", sort {length($b) <=> length($a) || $a cmp $b} @solutions; exit; __DATA__ alpha beta gamma delta epsilon
resulted in:
alephs behalf blahes bleach chapel Alpha Calpe abele abler ables albae + aleph amble ample apple babel bagel baled baler bales basel bathe be +ach belah belay belch belga bella blade blahs blame blare blase blaze + bleak blear bleat bleep bohea cable caleb chape cheap chela chelp Ab +el Ahab Alba Cape Cheb abbe abed abeg abet able ably ache ahem aiel a +ile alae alap albs alec alee ales alex aloe alps aped aper apes apex +apse axel axle babe bade bael bagh baht bail bake bald bale bali balk + ball balm bane bare base bash bate bawl bead beak beam bean beat bea +u beep bela bell belt bema beth bhan bile blab blah
It matched "behalf" which, with the letters, couldn't have matched. Any suggestions?

In reply to Re^2: scrambling all letters in a word until all combinations are found by Anonymous Monk
in thread scrambling all letters in a word until all combinations are found by Anonymous Monk

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.