Actually it is what I am doing. For each line in each file, I am comparing if they are equal or not. If yes they are stored in a temporary string, if no, they are pushed into two arrays.

On the next line, if previous line was different and line is starting with a +, they are appended to the last elements in arrays. If the previous line wasn't different, if the line is still not different, it is joined to the previous temporary string, otherwise it is pushed into the arrays.

In the end, if the line and all following lines are equal, the temporary string content is discarded.

However, the more I think about it, the more it seems I could miss a line or mishandle it. Therefore I think I will move into dealing each file first then comparing them.

Thanks for the head up on this solution. It seems it is what you all are leaning towards to: reading first, comparing later.


In reply to Re^2: Reading concurrently two files with different number of lines by frogsausage
in thread Reading concurrently two files with different number of lines by frogsausage

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.