Hello monks, please give me the script for this problem. How can i find the old substrings from file 1 in file 2 and how can i store the new beginnings and endings of the new substrings in file2.. Say you have one file that contains a sequence of letters, eg :
SGFEFHGYARSGVIMNDSGASTKSGAYITPAGETGGAIGRLGNQADTYVEMNLEHKQTLDN [file 1]
the same sequence is also in the [file 2], but, with "." and "-" in it, like:
...---SGFEF....HG-.--YARSGVI---MNDSGAS..--TKSGAY--....--ITPAG--ETGGAI. +.GRLGN--Q..AD---TY--V..EMNL--EHKQTLDN [file 2]
Let's say I want to check how two substrings (namely SGASTK and GNQADT) have become in file 2 compared to what they were in file1. I see that SGASTK, that was substring 19-24 in file1 is now SGAS..--TK and substring 36-41. GNQADT which was substring 42-48 in file1 is now GN--Q..AD---T and substring 76-82. I guess the answer is to turn the substrings you are looking for into regular expressions that accommodate the presence of '-' and '.' between the letters. For example,
#!/usr/local/bin/perl $str = "a-\.*?b-\.*?c"; $str2 = "zzzza---..bcddd +dd"; $str2 =~ /($str)/; print $1,"\n";
The use of the grouped regexp between /.../ allows you to remember the substring that matched the regexp. But i'm not sure with that,can you please give some idea or give me your script if it's possible.

Dec 18, 2025 at 20:06 UTC McDarren Added code tags


In reply to find the substring by roc

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.