in reply to Comparing strings (exact matches) in LARGE numbers FAST

I wouldn't use Perl; there are tools available to do this, and any POSIX compliant system will have them.
$ sort file1 > file1.sorted $ sort file2 > file2.sorted $ comm -12 file1.sorted file2.sorted

In bash (in several other shells probably as well, but I don't know them well enough), you can even do it as a one-liner, without the use of temporary files (*):

$ comm -12 <(sort file1) <(sort file2)

(*) Well, sort may use temporary files if the file to be sorted cannot be held in memory, but it'll clean up afterwards.

Replies are listed 'Best First'.
Re^2: Comparing strings (exact matches) in LARGE numbers FAST
by perlSD (Novice) on Aug 29, 2008 at 20:20 UTC
    Thanks, I completely forgot about the comm command...Since I am going to use the same 2nd (larger) file run after run , I will sort the file and save it sorted, so I won't have to do that over and over.
    Sorting such a large file may take close to an hour I would think... On my machine, sorthing a file with a few million strings like that takes at least a few minutes.