Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
this is probably a easy questions but I have two files file1 with about 490,000 numbers and file2 with about 24,000. file2s 24,000 exists in the file1 with 490,000. i want to take these out of file of file1. that would leave 464,000 in file1. how would i do this? here is what ive tried.
#!/usr/bin/env perl use strict; open(FILE1, "num_consol.orig"); open(FILE2, "num_status_43.out"); open(OUT, ">>new_num.lst"); for $file1 (<FILE1>){ chomp $file1; open(FILE2, "num_status_43.out"); for file2 (<FILE2>){ chomp $file2; if ($file1 ne '$file2'){ $cnt++;<br> print OUT "$file1\n"; } } } close OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: compare two files
by monarch (Priest) on Jul 24, 2007 at 13:18 UTC | |
|
Re: compare two files
by wojtyk (Friar) on Jul 24, 2007 at 13:48 UTC | |
by citromatik (Curate) on Jul 24, 2007 at 15:27 UTC | |
|
Re: compare two files
by dsheroh (Monsignor) on Jul 24, 2007 at 14:46 UTC | |
|
Re: compare two files
by citromatik (Curate) on Jul 24, 2007 at 15:33 UTC | |
|
Re: compare two files
by leocharre (Priest) on Jul 24, 2007 at 13:26 UTC |