Hello all-- New to Perl, new to this forum. Many thanks in advance for reading and offering help. I have a background in mathematics and have done a bit of programming, mostly for specific tasks that lead me to learn just enough of a language to achieve them. So I wouldn't call myself thoroughly conversant in any language. I am, however, interested in learning Perl more deeply, as I have some long-term projects that will require managing and searching through word lists in creative ways. I've been reading the O'Reilly book Learning Perl, but I have a specific problem that I need to solve somewhat urgently, and I'm afraid I haven't learned enough Perl yet to even attempt some code that could do it. So, here's the problem: I have a long list of text strings saved in a .txt file. What I am interested in are pairs of words that are exactly the same, except in one position . . . in particular, where one word has, say, an R, the other word has, say, an S. So if the word list was a standard dictionary and I ran the code on it, the output would include the pairs RAT and SAT, also RATE and SATE, also BARE and BASE, also BARR and BARS. This strikes me as something that should be possible using regular expressions in a Perl script. Am I right about that? If so, and if it's pretty easy for an expert to write some code that will do this, I would be much obliged, not just because I need a speedy solution to this question due to a deadline, but also because it will give me a great piece of example code to help me in getting my hands dirty learning Perl. All best-- Dominick

In reply to Comparing Lines within a Word List by dominick_t

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.