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

Re: Faster grep in a huge file(10 million)

by thewebsi (Beadle)
on May 10, 2013 at 19:56 UTC ( #1033016=note: print w/ replies, xml ) Need Help??


in reply to Faster grep in a huge file(10 million)

Sort the files first, then it's easy.


Comment on Re: Faster grep in a huge file(10 million)
Re^2: Faster grep in a huge file(10 million)
by Thomas Kennll (Acolyte) on May 10, 2013 at 20:09 UTC
    Thanks for the reply. I tried this but, doesn't seem to help . :(
    #!/usr/bin/perl use strict; use warnings; my %file2; open my $file2, '<', '/home/match_miss' or die "Couldn't open file2: $ +!"; while ( my $line = <$file2> ) { ++$file2{$line}; } open my $file1, '<', '/home/BIG_FILE' or die "Couldn't open file1: $!" +; while ( my $line = <$file1> ) { print $line if defined $file2{$line}; }
      print $line if defined $file2{$line};
      I think that finds lines in file 1 that are also in file 2. To find lines in file 1 not in file 2, maybe change that to:

      print $line unless defined $file2{$line};

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-08-29 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls