Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
guys lemme know if there is a best solution for this problem
there are 2 files which has to be compared line to line and their sizes are 60,000 lines each and the problem is to verify each file has same lines (dito matching) and which is the feasible solution............ i have thought of two things
1. break one of them in chunks of 3000 or 4000 then compare the other file with each chunk which wud reduce some time.
2. use binary search algorithm (one of the files is a sorted one) with file pointer positioning......
please i need the result at the earliest
Re: search a line in a file of 60,000 lines
by dave_the_m (Monsignor) on Aug 13, 2004 at 10:33 UTC
|
Are you just looking for a boolean output - ie just whether
the files differ? Or are you looking for more detailed output?
For the former, you could you the built-in File::Compare
module.
Dave. | [reply] |
Re: search a line in a file of 60,000 lines
by Gilimanjaro (Hermit) on Aug 13, 2004 at 11:40 UTC
|
If speed is your main concern, you might consider using the shell-solution; use 'sort' to sort the unsorted file, then 'diff' to compare them... | [reply] |
Re: search a line in a file of 60,000 lines
by sunadmn (Curate) on Aug 13, 2004 at 11:36 UTC
|
Well it sounds like you are trying to reinvent the wheel here why not take a look at File::Compare or try out Array::Compare I think this will be the easiest and fastest for you.
| [reply] |
Re: search a line in a file of 60,000 lines
by johnnywang (Priest) on Aug 13, 2004 at 17:24 UTC
|
| [reply] |
|