blib/lib/File/SimpleDiff.pm

filter: Statementstmt 16.4% 11 / 67 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 4 totaltotal 8.3% 13 / 156 CC 30 SCAR 47.4
CC
30
Cov
9%
diff
132.0
Intrsection
132.0
union
110.0
CRAP 114.5
↑ Summary
1 package File::SimpleDiff;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 require Exporter;
7  
8 2 our @ISA = qw(Exporter);
9  
10 2 our @EXPORT = qw(union diff Intrsection);
11  
12 2 our $VERSION = '1.09';
13  
14 sub union
15 0 ▶{
Subroutine union: not called CC=10 SCAR=47.0
Pod undocumented
16 #------------------------------------------------------------
17 # Function: to Find the union of lines among two files
18 #------------------------------------------------------------
19 0 ▶ my $Uni=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
20 0 ▶ my $file1=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
21 0 ▶ my $file2=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
22 0 ▶ open (IN1,"$file1") || die "cannot open $file1:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN1, "$file1" or die "cannot open ${file1}:$!\n" 0 0 0
23 0 ▶ open (IN2,"$file2") || die "cannot open $file2:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN2, "$file2" or die "cannot open ${file2}:$!\n" 0 0 0
24 0 ▶ if ($Uni eq 'or') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Uni eq 'or') { } 0 0 0
25 0 my %out;
26 0 ▶ while(<IN1>) {chomp;$out{$_}=1;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN1)) 0 0 0
27 0 ▶ while(<IN2>) {chomp;$out{$_}=1;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN2)) 0 0 0
28 0 foreach (keys %out) {print "$_\n";}
29 }
30 else
31 {
32 0 help();
33 }
34 0 close IN1;
35 0 close IN2;
36 }
37  
38 sub diff
39 0 ▶{
Subroutine diff: not called CC=11 SCAR=48.8
Pod undocumented
40 #------------------------------------------------------------
41 # Function: to Find the difference of lines among two files
42 #------------------------------------------------------------
43 0 ▶ my $Diff=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
44 0 ▶ my $file1=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
45 0 ▶ my $file2=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
46 0 ▶ open (IN1,"$file1") || die "cannot open $file1:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN1, "$file1" or die "cannot open ${file1}:$!\n" 0 0 0
47 0 ▶ open (IN2,"$file2") || die "cannot open $file2:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN2, "$file2" or die "cannot open ${file2}:$!\n" 0 0 0
48 0 ▶ if ($Diff eq 'diff') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Diff eq 'diff') { } 0 0 0
49 0 my %in2;my %out;
50 0 ▶ while(<IN2>) {chomp;$in2{$_}=1;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN2)) 0 0 0
51 0 ▶ while(<IN1>) {chomp;$out{$_}=1 if(not exists $in2{$_});}
Branch: 2 branches
BranchTrueFalseTotal
if (defined($_ = readline IN1)) 0 0 0
unless exists $in2{$_} 0 0 0
52 0 foreach (keys %out) {print "$_\n";}
53 }
54 else
55 {
56 0 help();
57 }
58 0 close IN1;
59 0 close IN2;
60 }
61  
62 sub Intrsection
63 0 ▶{
Subroutine Intrsection: not called CC=11 SCAR=48.8
Pod undocumented
64 #------------------------------------------------------------
65 # Function: to Find the intersection of lines among two files
66 #------------------------------------------------------------
67 0 ▶ my $Intr=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
68 0 ▶ my $file1=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
69 0 ▶ my $file2=shift || help();
Condition0%0/3
shift() || help()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || help()
shift() help()
Truth table0%0/3
A || B
A= shift()B= help()
ABresult
1X1
011
000
70 0 ▶ open (IN1,"$file1") || die "cannot open $file1:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN1, "$file1" or die "cannot open ${file1}:$!\n" 0 0 0
71 0 ▶ open (IN2,"$file2") || die "cannot open $file2:$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open IN2, "$file2" or die "cannot open ${file2}:$!\n" 0 0 0
72 0 ▶ if ($Intr eq 'and') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Intr eq 'and') { } 0 0 0
73 0 my %in1;my %out;
74 0 ▶ while(<IN1>) {chomp;$in1{$_}=1;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline IN1)) 0 0 0
75 0 ▶ while(<IN2>) {chomp;$out{$_}=1 if(exists $in1{$_});}
Branch: 2 branches
BranchTrueFalseTotal
if (defined($_ = readline IN2)) 0 0 0
if exists $in1{$_} 0 0 0
76 0 foreach (keys %out) {print "$_\n";}
77 }
78 else
79 {
80 0 help();
81 }
82 0 close IN1;
83 0 close IN2;
84 }
85  
86 sub help
87 0 ▶{
Subroutine help: not called CC=1 SCAR=6.9
Pod undocumented
88 0 print "File::SimpleDiff : compare two Files with \'[or/diff/and]\' options... \nUsage:\tFile::SimpleDiff [-h] :for help,info\n\tunion('or','file1.txt','file2.txt') : union of two sets\n\tdiff('diff','file1.txt','file2.txt');: elements in A but not in B\n\tIntrsection('and','file1.txt','file2.txt'); : intersection of two sets\n";
89 0 exit 1;
90 }
91  
92 2 1;
93  
94 __END__
↑ Summary