ilottl has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w #use strict; sub slurp{ local *ARGV; @ARGV = @_; <> } my %where; $file1 = "c:\\gpTemp\\chris\\validation\\brookdeliv\.txt"; $file2 = "c:\\gpTemp\\chris\\validation\\LD\.txt"; $both = "c:\\gpTemp\\chris\\validation\\ld\\Acts_delivered\.txt"; $infile1 = "c:\\gpTemp\\chris\\validation\\ld\\Acts_Missing\.txt"; $infile2 = "c:\\gpTemp\\chris\\validation\\ld\\Acts_Extra\.txt"; open BOTH, "> $both" or die "Cannot open $new for writing: $!"; open INFILE1, "> $infile1" or die "Cannot open $new for writing: $!"; open INFILE2, "> $infile2" or die "Cannot open $new for writing: $!"; $where{$_} .= "1" for slurp($file1); $where{$_} .= "2" for slurp($file2); for (sort keys %where) { my $where = $where{$_}; if ($where =~ /12/) { print BOTH; } elsif ($where =~ /1/) { print INFILE1; } else { print INFILE2; } print ":\t$_"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding duplicates in a text file
by Util (Priest) on Jun 06, 2007 at 05:39 UTC | |
|
Re: Finding duplicates in a text file
by GrandFather (Saint) on Jun 06, 2007 at 04:12 UTC |