line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::SimpleDiff; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
51192
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
558
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(union diff Intrsection); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.09'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub union |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
#------------------------------------------------------------ |
17
|
|
|
|
|
|
|
# Function: to Find the union of lines among two files |
18
|
|
|
|
|
|
|
#------------------------------------------------------------ |
19
|
0
|
|
0
|
0
|
0
|
|
my $Uni=shift || help(); |
20
|
0
|
|
0
|
|
|
|
my $file1=shift || help(); |
21
|
0
|
|
0
|
|
|
|
my $file2=shift || help(); |
22
|
0
|
0
|
|
|
|
|
open (IN1,"$file1") || die "cannot open $file1:$!\n"; |
23
|
0
|
0
|
|
|
|
|
open (IN2,"$file2") || die "cannot open $file2:$!\n"; |
24
|
0
|
0
|
|
|
|
|
if ($Uni eq 'or') { |
25
|
0
|
|
|
|
|
|
my %out; |
26
|
0
|
|
|
|
|
|
while() {chomp;$out{$_}=1;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
while() {chomp;$out{$_}=1;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
foreach (keys %out) {print "$_\n";} |
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
|
help(); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
close IN1; |
35
|
0
|
|
|
|
|
|
close IN2; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub diff |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
#------------------------------------------------------------ |
41
|
|
|
|
|
|
|
# Function: to Find the difference of lines among two files |
42
|
|
|
|
|
|
|
#------------------------------------------------------------ |
43
|
0
|
|
0
|
0
|
0
|
|
my $Diff=shift || help(); |
44
|
0
|
|
0
|
|
|
|
my $file1=shift || help(); |
45
|
0
|
|
0
|
|
|
|
my $file2=shift || help(); |
46
|
0
|
0
|
|
|
|
|
open (IN1,"$file1") || die "cannot open $file1:$!\n"; |
47
|
0
|
0
|
|
|
|
|
open (IN2,"$file2") || die "cannot open $file2:$!\n"; |
48
|
0
|
0
|
|
|
|
|
if ($Diff eq 'diff') { |
49
|
0
|
|
|
|
|
|
my %in2;my %out; |
50
|
0
|
|
|
|
|
|
while() {chomp;$in2{$_}=1;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
while() {chomp;$out{$_}=1 if(not exists $in2{$_});} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach (keys %out) {print "$_\n";} |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
|
help(); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
close IN1; |
59
|
0
|
|
|
|
|
|
close IN2; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub Intrsection |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
#------------------------------------------------------------ |
65
|
|
|
|
|
|
|
# Function: to Find the intersection of lines among two files |
66
|
|
|
|
|
|
|
#------------------------------------------------------------ |
67
|
0
|
|
0
|
0
|
0
|
|
my $Intr=shift || help(); |
68
|
0
|
|
0
|
|
|
|
my $file1=shift || help(); |
69
|
0
|
|
0
|
|
|
|
my $file2=shift || help(); |
70
|
0
|
0
|
|
|
|
|
open (IN1,"$file1") || die "cannot open $file1:$!\n"; |
71
|
0
|
0
|
|
|
|
|
open (IN2,"$file2") || die "cannot open $file2:$!\n"; |
72
|
0
|
0
|
|
|
|
|
if ($Intr eq 'and') { |
73
|
0
|
|
|
|
|
|
my %in1;my %out; |
74
|
0
|
|
|
|
|
|
while() {chomp;$in1{$_}=1;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
while() {chomp;$out{$_}=1 if(exists $in1{$_});} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
foreach (keys %out) {print "$_\n";} |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
|
|
|
help(); |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
close IN1; |
83
|
0
|
|
|
|
|
|
close IN2; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub help |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |