Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

search a line in a file of 60,000 lines

by Anonymous Monk
on Aug 13, 2004 at 10:25 UTC ( [id://382597]=perlquestion: print w/replies, xml ) Need Help??

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
  • Comment on search a line in a file of 60,000 lines

Replies are listed 'Best First'.
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.

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...
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.
    SUNADMN
    USE PERL
Re: search a line in a file of 60,000 lines
by johnnywang (Priest) on Aug 13, 2004 at 17:24 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://382597]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-25 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found