65
|
|
|
|
|
|
|
~; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _build_table { |
69
|
7
|
|
|
7
|
|
16
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
22
|
my %files = @_; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
30
|
my @seq_a = $self->_read_file( $files{a} ); |
74
|
7
|
|
|
|
|
34
|
my @seq_b = $self->_read_file( $files{b} ); |
75
|
|
|
|
|
|
|
|
76
|
7
|
|
|
|
|
67
|
my $diff = Algorithm::Diff->new( \@seq_a, \@seq_b ); |
77
|
|
|
|
|
|
|
|
78
|
7
|
|
|
|
|
2799
|
$diff->Base(1); |
79
|
|
|
|
|
|
|
|
80
|
7
|
|
|
|
|
65
|
my $rows = ''; |
81
|
|
|
|
|
|
|
|
82
|
7
|
|
|
|
|
22
|
my ($line_nr_a, $line_nr_b) = (1, 1); |
83
|
7
|
|
|
|
|
31
|
while ( $diff->Next ) { |
84
|
55
|
100
|
|
|
|
1150
|
if ( my $count = $diff->Same ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
85
|
27
|
|
|
|
|
566
|
for my $string ( $diff->Same ) { |
86
|
37
|
|
|
|
|
593
|
$rows .= $self->_add_tablerow( |
87
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
88
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
89
|
|
|
|
|
|
|
line_a => $string, |
90
|
|
|
|
|
|
|
line_b => $string, |
91
|
|
|
|
|
|
|
color_a => '', |
92
|
|
|
|
|
|
|
color_b => '', |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
elsif ( !$diff->Items(2) ) { |
97
|
5
|
|
|
|
|
195
|
my @items_1 = $diff->Items(1); |
98
|
5
|
|
|
|
|
112
|
my @items_2 = $diff->Items(2); |
99
|
|
|
|
|
|
|
|
100
|
5
|
50
|
|
|
|
80
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
101
|
|
|
|
|
|
|
|
102
|
5
|
|
|
|
|
22
|
for my $index ( 1 .. $max ) { |
103
|
5
|
|
50
|
|
|
66
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
104
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
105
|
|
|
|
|
|
|
line_nr_b => '', |
106
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
107
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
108
|
|
|
|
|
|
|
color_a => 'red', |
109
|
|
|
|
|
|
|
color_b => '', |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ( !$diff->Items(1) ) { |
114
|
10
|
|
|
|
|
328
|
my @items_1 = $diff->Items(1); |
115
|
10
|
|
|
|
|
139
|
my @items_2 = $diff->Items(2); |
116
|
|
|
|
|
|
|
|
117
|
10
|
50
|
|
|
|
154
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
118
|
|
|
|
|
|
|
|
119
|
10
|
|
|
|
|
30
|
for my $index ( 1 .. $max ) { |
120
|
10
|
|
50
|
|
|
73
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
121
|
|
|
|
|
|
|
line_nr_a => '', |
122
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
123
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
124
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
125
|
|
|
|
|
|
|
color_a => '', |
126
|
|
|
|
|
|
|
color_b => 'green', |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
else { |
131
|
13
|
|
|
|
|
449
|
my @items_1 = $diff->Items(1); |
132
|
13
|
|
|
|
|
197
|
my @items_2 = $diff->Items(2); |
133
|
|
|
|
|
|
|
|
134
|
13
|
50
|
|
|
|
202
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
135
|
|
|
|
|
|
|
|
136
|
13
|
|
|
|
|
35
|
for my $index ( 1 .. $max ) { |
137
|
26
|
|
100
|
|
|
148
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
138
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
139
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
140
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
141
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
142
|
|
|
|
|
|
|
color_a => 'red', |
143
|
|
|
|
|
|
|
color_b => 'green', |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
7
|
|
|
|
|
289
|
return $rows; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _add_tablerow { |
153
|
83
|
|
|
83
|
|
1458
|
my $self = shift; |
154
|
|
|
|
|
|
|
|
155
|
83
|
|
|
|
|
280
|
my %params = @_; |
156
|
|
|
|
|
|
|
|
157
|
83
|
|
|
|
|
183
|
my ($line_nr_a, $line_a, $color_a) = @params{qw/line_nr_a line_a color_a/}; |
158
|
83
|
|
|
|
|
159
|
my ($line_nr_b, $line_b, $color_b) = @params{qw/line_nr_b line_b color_b/}; |
159
|
|
|
|
|
|
|
|
160
|
83
|
100
|
|
|
|
220
|
$color_a = $color_a ? qq~style="color: $color_a;"~ : ''; |
161
|
83
|
100
|
|
|
|
149
|
$color_b = $color_b ? qq~style="color: $color_b;"~ : ''; |
162
|
|
|
|
|
|
|
|
163
|
83
|
|
100
|
|
|
241
|
$line_a = encode_entities( $line_a // '' ); |
164
|
83
|
|
100
|
|
|
1271
|
$line_b = encode_entities( $line_b // '' ); |
165
|
|
|
|
|
|
|
|
166
|
83
|
|
|
|
|
977
|
$line_a =~ s{ }{ }g; |
167
|
83
|
|
|
|
|
159
|
$line_b =~ s{ }{ }g; |
168
|
|
|
|
|
|
|
|
169
|
83
|
|
|
|
|
532
|
my $row = qq~ |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
| $line_nr_a |
172
|
|
|
|
|
|
|
| $line_a |
173
|
|
|
|
|
|
|
| $line_nr_b |
174
|
|
|
|
|
|
|
| $line_b |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
~; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub _end_table { |
180
|
7
|
|
|
7
|
|
22
|
my $self = shift; |
181
|
|
|
|
|
|
|
|
182
|
7
|
|
|
|
|
27
|
return qq~ |
183
|
|
|
|
|
|
|
|