in reply to Compare 2 files and create a new one if it matches
# assumes that duplicates in first file should be ignored. my %wanted; open my $in, '<', '$file1' or die "$!\n"; while (my $line = <$in>) { chomp $line); $wanted{$line}++; }
my $foo = (split /|/, $line)[1];
print OUT $line if $wanted{$foo};
This may not be the fastest approach, but it does only open and read each of your input files once. As opposed to 60,000 X 16,000,000 = 960,000,000,000 times - which is what your current code does.
So I'd expect it to be just a tad faster ;)
Hope this helps,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Compare 2 files and create a new one if it matches
by GrandFather (Saint) on Sep 20, 2008 at 03:39 UTC |