sarvan has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my $f1 = $ARGV[0]; open FILE1, "$f1" or die "Could not open file \n"; my $f2= 'res1.txt'; open FILE2, "$f2" or die "Could not open file \n"; my $outfile = $ARGV[1]; my @outlines; my $n=0; my $n1=0; my $n2=0; foreach (<FILE1>) { my $y = 0; my $outer_text = $_; seek(FILE2,0,0); foreach (<FILE2>) { my $inner_text = $_; if($outer_text eq $inner_text) { $y = 1; print "$outer_text, Match found \n"; $n++; last; } } if($y != 1) { print "$outer_text,No Match Found \n"; push(@outlines, $outer_text); $n1++; } $n2++; } print "Total No.of queries:$n2\n"; print "No.of matched entries:$n\n"; print "No.of Mis-matched entries:$n1\n"; my $precision=$n/$n2; print "The precision is:$precision\n"; open (OUTFILE, ">Nonmatch") or die "Cannot open $outfile for writing \ +n"; print OUTFILE @outlines; close OUTFILE; close FILE1; close FILE2;
The script compares the two text file and gives the no.of matches and no.of mismatches. Also it writes mis-match into seperate file.
My doubt is when comparing the two file, if the 1st file has a sentence in line2(for e.g) and the 2nd file has empty space at line2, what happens is it takes that also has a mis-match. But what i want is, i want to differetiate the no.result(i.e empty space) from mis-match..
How can i do that.. Plz suggest me in this... Thanks..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: on matching content of two text files
by jethro (Monsignor) on Aug 11, 2011 at 09:12 UTC | |
|
Re: on matching content of two text files
by Skeeve (Parson) on Aug 11, 2011 at 06:10 UTC |