coding: use Getopt::Long qw(:config no_ignore_case); use Data::Dumper; use POSIX qw(floor); use strict; use warning; my $orig = ''; my $new = ''; GetOptions('orig=s' => \$orig, 'new=s' => \$new); if (!$orig|!$new) { print "\n\t Help: test.pl -orig -new \n"; exit; } open (PASS, ">pass.rpt") || die "ERROR: cannot open"; open (FAIL, ">fail.rpt") || die "ERROR: cannot open"; open (NC, ">noCheck.rpt") || die "ERROR: cannot open"; open (t1, ">t1") || die "ERROR: cannot open"; open (t2, ">t2") || die "ERROR: cannot open"; my (@array, $line, $end1, $slack1, $b1, $THIS, @arr1, @arr2, @tmp1, @tmp2, @emp, @emp2, $data1, $data2,$emp1,$emp2,$emp3,$emp4,$ep1,$s1,$ep2,$s2,$ncc,$pc,$fc); $ncc = 0; $pc = 0; $fc = 0; fileA_ext(); fileB_ext(); check(); #_______________________________________________________________________________________________ sub fileA_ext() { if ($orig =~ /\S+\.gz$/) { open (FileA,"gunzip -c $orig |") || die "ERROR: can't read $orig\n"; } else { open (FileA,"$orig") || die "ERROR: can't read $orig\n"; } while (@array = ) { foreach $line(@array) { if ($line =~ m/(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) { if ($line !~ m/\((sa)\)/) { @arr1 = @emp; next if ($line =~ m/Name/); $name1 = "$1"; $score1 = "$12"; my $data1 = join(";",$name1,$score1); push (@arr1, $data1); } if ($line =~ m/\((sa)\)/) { @arr1 = @emp2; @tmp1 = @emp; next if ($line =~ m/Name/); push (@tmp1, $line); #print t "@tmp1\n"; foreach $line (@tmp1) { if ($line =~ m/(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) { my $name2 = "$1"; substr($name2, -13) = ''; my $score2 = "$12"; my $data1 = join(";",$name2,$score2); push (@arr1, $data1); $name2 = $score2 =""; #print "@arr1\n\n"; } } } print t1 "@arr1\n\n"; } } } close (FileA); } #____________________________________________________________________________________________ sub FileB_ext() { if ($new =~ /\S+\.gz$/) { open (FileB,"gunzip -c $new |") || die "ERROR: $THIS can't read $new\n"; } else { open (FileB,"$new") || die "ERROR: $THIS can't read $new\n"; } while (@array = ) { foreach $line(@array) { if ($line =~ m/(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) { #print "$line\n"; if ($line !~ m/\((sa)\)/) { @arr2 = @emp; next if ($line =~ m/Name/); my $name3 = "$1"; my $score3 = "$12"; my $data2 = join(";",$name3,$score3); push (@arr2, $data2); } if ($line =~ m/\((sa)\)/) { @arr2 = @emp2; @tmp2 = @emp; next if ($line =~ m/Name/); push (@tmp2, $line); #print t "@tmp2\n"; foreach $line (@tmp2) { if ($line =~ m/(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)/) { my $name4 = "$1"; substr($name4, -13) = ''; my $score4 = "$12"; my $data2 = join(";",$name4,$score4); push (@arr2, $data2); $name4 = $score4 =""; #print "@arr2\n\n"; } } } print t2 "@arr2\n\n"; } } } close (FileB); } sub check() { foreach $data1 (@arr1) { if ($data1 ne ""){ if ($data1 =~ m/(.*)\;(.*)/) { $ep1 = $emp1; $s1 = $emp2; my $ep1 = "$1"; my $s1 = "$2"; #print r "$ep1 $s1\n\n"; foreach $data2 (@arr2) { if ($data2 ne "") { if ($data2 =~ m/(.*)\;(.*)/) { $ep2 = $emp3; $s2 = $emp4; my $ep2 = "$1"; my $s2 = "$2"; #print R "$ep2 $s2\n"; if ( $ep1 eq $ep2 && $s1 =~ m/-/g) { $ncc++; #print NC "Total match: $ncc\n\n"; print NC "$ep1 $s1 $s2\n"; } if ( $ep1 eq $ep2 && $s1 !~ m/-/g && $s1 > 50 && $s2 > 40) { $pc++; print PASS "$ep1 $s1 $s2\n"; } if ( $ep1 eq $ep2 && $s1 !~ m/-/g && $s1 < 50 && $s2 < 40) { $fc++; print FAIL "$ep1 $s1 $s2\n"; } } } } } } } print NC "\nTotal match: $ncc\n\n"; print PASS "\nTotal match: $pc\n\n"; print FAIL "\nTotal match: $fc\n\n"; }