clean up script -- difference between two files

#!/usr/bin/perl


my $totalfile = $ARGV[0];
my $suspectfile = $ARGV[1];
my $outfile = $ARGV[2];

if ($#ARGV != 2) {
print "user script.pl realfile suspectfiel goodfile\n" ;
exit;
}

local $/;
open (SUS,"<" ,$suspectfile) or die " cannot open file " ;
my @allsus = split /\n/, <SUS>;
close( SUS) ;


open (TOT,"<" ,$totalfile) or die " cannot open file " ;
my @total = split /\n/, <TOT>;
close (TOT) ;

my %allsus = map {$_ => 1 } @allsus;

my @allgood = grep {!defined $allsus{$_ } } @total ;

my @new = join "\n", @allgood;

open (OUT,">",$outfile ) or die " cannot open file ";
print OUT "@new";
close (OUT);


Other Articles

Enter your email address: