I have two files list.txt and list1.txt where as list.txt contains a line form1-data and list1.txt contains a line data I want to compare these two files and output should be printed as form1-data (form1 represents list1.txt first column and data represents list1.txt first column). I want to compare these two files for 100 lines.
my $f1 = '<',"/home/httpd/cgi-bin/u/r/list.txt";
my $f2 = '<',"/home/httpd/cgi-bin/u/r/list1.txt";
my $outfile = "";
my %results = ();
open FILE1, "$f1" || die "error \n";
while(my $line = <FILE1>){
$results{$line}=1;
}
close(FILE1);
open FILE2, "$f2" || die "error \n";
while(my $line =<FILE2>) {
$results{$line}++;
}
close(FILE2);
open (OUTFILE, '>',"/home/httpd/cgi-bin/u/r/outfile") || die" error \n";
foreach my $line (keys %results) {
print OUTFILE $line if $results{$line} == 1;
}
close OUTFILE;`
file.txt(UP-Myco sme UP-Myco tube UP-Myco abs UP-Myco absces) file1.txt contains(Myco absces Myco afri Myco avi Myco bovis) expected output:UP-Myco absces(by comparing two files need to print the ABOVE OUTPUT)
Aucun commentaire:
Enregistrer un commentaire