Hi monks,
I'm trying to create a cryptquote solver as a bit of an academic exercise to learn more about various aspects of Perl.

I've come across a roadblock, what I am trying to do is make a regex to check a dictionary file for words that match a pattern given by the encrypted word...Here is a piece of code to check one word against a dictionary file to see if it fits the pattern...(pattern is abcdee)
#!Perl open INPUT, "<dictionary"; open OUTPUT, ">result.txt"; while (<INPUT>){ if ($_ =~ m/^(.)([^\1])([^\1\2])([^\1\2\3])([^\1\2\3\4])\5/i){ print OUTPUT "$&\n"; } }
I'm sure it is easy to see what I am trying to do here, but obviously I have something wrong. Once I get the regex right, I would like to dynamically generate the regex for each word and then map the results so that the next word only looks at words that match the letters seen for the last word (but that's the next phase). This will be a recursive process, so that if the prog hits a roadblock (from thinking that one of the words is something it really isn't) it will go back and try something else.

This is something that I took on as a whim, and now I realize that it is much more complex than I thought. I'm still learning Perl though, and I think that taking on hard things is probably the best way to learn how to handle hard things...

Any advice?
XC

In reply to cryptquote solver by xChauncey

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.