| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Presenter::Combo::Intersect; |
|
2
|
|
|
|
|
|
|
#$Id: Intersect.pm 1218 2008-02-10 00:11:59Z jimk $ |
|
3
|
|
|
|
|
|
|
$VERSION = 1.03; # 02-10-2008 |
|
4
|
|
|
|
|
|
|
@ISA = qw(Data::Presenter::Combo); |
|
5
|
3
|
|
|
3
|
|
8472
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
142
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
113
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use Data::Dumper; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1312
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our %reserved_partial = ( |
|
10
|
|
|
|
|
|
|
'fields' => 1, |
|
11
|
|
|
|
|
|
|
'index' => 1, |
|
12
|
|
|
|
|
|
|
'options' => 1, |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _merge_engine { |
|
16
|
6
|
|
|
6
|
|
13
|
my ($self, $mergeref) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
6
|
|
|
|
|
10
|
my %base = %{${$mergeref}{base}}; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
48
|
|
|
19
|
6
|
|
|
|
|
33
|
my %sec = %{${$mergeref}{secondary}}; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
37
|
|
|
20
|
6
|
|
|
|
|
14
|
my %newbase = %{${$mergeref}{newbase}}; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
20
|
|
|
21
|
6
|
|
|
|
|
10
|
my %secneeded = %{${$mergeref}{secfieldsneeded}}; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
23
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
18
|
my %seenboth = (); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Work thru the entries in the base ... |
|
26
|
6
|
|
|
|
|
31
|
foreach my $i (keys %base) { |
|
27
|
|
|
|
|
|
|
# reserved entry qw| parameters | gets built here without any fuss |
|
28
|
|
|
|
|
|
|
# reserved entries qw| fields index options | get built in Combo.pm |
|
29
|
77
|
100
|
|
|
|
344
|
unless ($reserved_partial{$i}) { |
|
30
|
|
|
|
|
|
|
# and build up a look-up table %seenboth where each key is an entry |
|
31
|
|
|
|
|
|
|
# in the base found in BOTH base and sec |
|
32
|
|
|
|
|
|
|
# i.e., the intersection of base and sec |
|
33
|
65
|
|
|
|
|
175
|
foreach my $j (keys %sec) { |
|
34
|
647
|
100
|
|
|
|
1173
|
if ($i eq $j) { |
|
35
|
24
|
|
|
|
|
44
|
$seenboth{$i} = 1; |
|
36
|
24
|
|
|
|
|
55
|
last; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Work thru the look-up table ... |
|
43
|
6
|
|
|
|
|
16
|
my $null = q{}; |
|
44
|
6
|
|
|
|
|
97
|
foreach my $rec (keys %seenboth) { |
|
45
|
24
|
|
|
|
|
32
|
my (@basevalues, @secvalues); |
|
46
|
|
|
|
|
|
|
# 1. Assign the values encountered first in base |
|
47
|
24
|
|
|
|
|
33
|
my @record = @{$base{$rec}}; |
|
|
24
|
|
|
|
|
84
|
|
|
48
|
24
|
|
|
|
|
68
|
for (my $q=0; $q < scalar(@record); $q++) { |
|
49
|
180
|
|
|
|
|
462
|
$basevalues[$q] = $record[$q]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
# 2. Assign the values encountered first in sec |
|
52
|
|
|
|
|
|
|
# (%secneeded's keys are numbers: field's subscripts in sec |
|
53
|
24
|
|
|
|
|
81
|
foreach my $i (sort {$a <=> $b} keys %secneeded) { |
|
|
52
|
|
|
|
|
105
|
|
|
54
|
68
|
|
|
|
|
141
|
push @secvalues, $sec{$rec}[$i]; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
24
|
|
|
|
|
142
|
$newbase{$rec} = [@basevalues, @secvalues]; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
6
|
|
|
|
|
51
|
return \%newbase; |
|
59
|
|
|
|
|
|
|
# Note: This is actually newbase less the 'fields' and 'index' entries |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
############################## DOCUMENTATION ############################## |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Data::Presenter::Combo::Intersect |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This document refers to version 1.03 of Data::Presenter::Combo::Intersect, released February 10, 2008. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This package is a subclass of, and inherits from, Data::Presenter::Combo. Please see the Data::Presenter documentation to learn how to use Data::Presenter::Combo::Intersect. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHOR |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
James E. Keenan (jkeenan@cpan.org). |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Creation date: October 28, 2001. Last modification date: February 10, 2008. |
|
83
|
|
|
|
|
|
|
Copyright (c) 2001-5 James E. Keenan. United States. All rights reserved. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
All data presented in this documentation or in the sample files in the |
|
86
|
|
|
|
|
|
|
archive accompanying this documentation are dummy copy. The data was |
|
87
|
|
|
|
|
|
|
entirely fabricated by the author for heuristic purposes. Any resemblance |
|
88
|
|
|
|
|
|
|
to any person, living or dead, is coincidental. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software which you may distribute under the same terms as |
|
91
|
|
|
|
|
|
|
Perl itself. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|