Hello, Can someone help out with a perl script to compare two files and print the difference along with segment name under which the difference is

Requirement I have tst1.txt and tst2.txt tst1.txt have data as below Note: ABCD & EFGH are segments in below data ABCD TEST1 TEST2 TEST3 EFGH TEST1 TEST2 TEST3 tst2.txt have data as below ABCD TEST1 TEST2 TEST3 EFGH TEST1 TEST2 TEST3 TEST4 TEST5 Now diff between two files is in tst2.txt the last two rows "TEST4", " +TEST5" I need to have a script which gives output as below Diff between two files is from segment EFGH TEST4 TEST5

I am calling EFGH as segment, and it is must to have it in output file eventhough segment name is same from both files(ex: EFGH from above data). Also the the text files contains around 2 thousand to 3 thousand records. I need to find out difference along with under which segment(Name) the difference is. Pls help..


In reply to Need to have perl script to compare two txt files and print difference along with under which segment the difference is by User_04271983

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.