| 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()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 20 | 0 | ▶ | my $file1=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 21 | 0 | ▶ | my $file2=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 22 | 0 | ▶ | open (IN1,"$file1") || die "cannot open $file1:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 0 | ▶ | open (IN2,"$file2") || die "cannot open $file2:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | ▶ | if ($Uni eq 'or') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | my %out; | |||||||||||||||||||
| 26 | 0 | ▶ | while(<IN1>) {chomp;$out{$_}=1;} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 0 | ▶ | while(<IN2>) {chomp;$out{$_}=1;} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 44 | 0 | ▶ | my $file1=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 45 | 0 | ▶ | my $file2=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 46 | 0 | ▶ | open (IN1,"$file1") || die "cannot open $file1:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 0 | ▶ | open (IN2,"$file2") || die "cannot open $file2:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 0 | ▶ | if ($Diff eq 'diff') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | my %in2;my %out; | |||||||||||||||||||
| 50 | 0 | ▶ | while(<IN2>) {chomp;$in2{$_}=1;} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | ▶ | while(<IN1>) {chomp;$out{$_}=1 if(not exists $in2{$_});} | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 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()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 68 | 0 | ▶ | my $file1=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 69 | 0 | ▶ | my $file2=shift || help(); | ||||||||||||||||||
|
Condition0%0/3
shift() || help()
MC/DC0%0/2
shift() || help()
shift()
help()
Truth table0%0/3
A || B
A= shift()B= help()
| |||||||||||||||||||||
| 70 | 0 | ▶ | open (IN1,"$file1") || die "cannot open $file1:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 0 | ▶ | open (IN2,"$file2") || die "cannot open $file2:$!\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 0 | ▶ | if ($Intr eq 'and') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 0 | my %in1;my %out; | |||||||||||||||||||
| 74 | 0 | ▶ | while(<IN1>) {chomp;$in1{$_}=1;} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 0 | ▶ | while(<IN2>) {chomp;$out{$_}=1 if(exists $in1{$_});} | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||