Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
We don't bite newbies here... much
 
PerlMonks  

Re: Reading concurrently two files with different number of lines

by talexb (Canon)
on Apr 10, 2013 at 17:46 UTC ( #1028016=note: print w/ replies, xml ) Need Help??


in reply to Reading concurrently two files with different number of lines

If a line starting with a '+' is a continuation, would it make sense to add that to the previous line, and then do the comparisons once all of the continuations have been dealt with?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re: Reading concurrently two files with different number of lines
Re^2: Reading concurrently two files with different number of lines
by frogsausage (Sexton) on Apr 11, 2013 at 08:51 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-04-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (462 votes), past polls