line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Load::Method; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
58
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
167
|
|
4
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
179
|
|
5
|
6
|
|
|
|
|
5179
|
use SQL::Load::Util qw/ |
6
|
|
|
|
|
|
|
parse |
7
|
|
|
|
|
|
|
name_list |
8
|
6
|
|
|
6
|
|
31
|
/; |
|
6
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
28
|
|
|
28
|
1
|
62
|
my ($class, $content, $end) = @_; |
12
|
|
|
|
|
|
|
|
13
|
28
|
|
|
|
|
67
|
my ($data, $hash, $keys, $list) = $class->_parse($content, $end); |
14
|
|
|
|
|
|
|
|
15
|
28
|
|
|
|
|
100
|
my $self = { |
16
|
|
|
|
|
|
|
_data => $data, |
17
|
|
|
|
|
|
|
_hash => $hash, |
18
|
|
|
|
|
|
|
_keys => $keys, |
19
|
|
|
|
|
|
|
_list => $list, |
20
|
|
|
|
|
|
|
_next => 0 |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
28
|
|
|
|
|
119
|
return bless $self, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub default { |
27
|
4
|
|
|
4
|
1
|
825
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
4
|
50
|
|
|
|
13
|
return $self->{_hash}->{default} if exists $self->{_hash}->{default}; |
30
|
4
|
50
|
|
|
|
23
|
return $self->{_list}->[0] if exists $self->{_list}->[0]; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub name { |
36
|
47
|
|
|
47
|
1
|
2961
|
my ($self, $name) = @_; |
37
|
|
|
|
|
|
|
|
38
|
47
|
50
|
|
|
|
140
|
my $real = exists $self->{_keys}->{$name} ? $self->{_keys}->{$name} : $name; |
39
|
|
|
|
|
|
|
|
40
|
47
|
50
|
|
|
|
339
|
return $self->{_hash}->{$real} if exists $self->{_hash}->{$real}; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub next { |
46
|
14
|
|
|
14
|
1
|
29
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
14
|
100
|
|
|
|
38
|
if (defined $self->{_next}) { |
49
|
13
|
|
|
|
|
23
|
my $next = $self->{_next}++; |
50
|
|
|
|
|
|
|
|
51
|
13
|
100
|
|
|
|
58
|
return $self->{_list}->[$next] if exists $self->{_list}->[$next]; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
7
|
$self->{_next} = undef; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
16
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub at { |
60
|
8
|
|
|
8
|
1
|
29
|
my ($self, $index) = @_; |
61
|
|
|
|
|
|
|
|
62
|
8
|
50
|
|
|
|
63
|
return $self->{_list}->[$index - 1] if exists $self->{_list}->[$index - 1]; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub first { |
68
|
5
|
|
|
5
|
1
|
11
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
5
|
|
|
|
|
21
|
return $self->{_list}->[0]; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub last { |
74
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
7
|
return $self->{_list}->[-1]; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub replace { |
80
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
9
|
my %replace = @_; |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
9
|
for my $name (keys %replace) { |
85
|
3
|
|
|
|
|
7
|
my $value = $replace{$name}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# replace in hash |
88
|
3
|
|
|
|
|
4
|
for my $key (keys %{$self->{_hash}}) { |
|
3
|
|
|
|
|
10
|
|
89
|
5
|
|
|
|
|
50
|
$self->{_hash}->{$key} =~ s/${name}/${value}/g; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# replace in list |
93
|
3
|
|
|
|
|
9
|
for (my $i = 0; $i < scalar(@{$self->{_list}}); $i++) { |
|
8
|
|
|
|
|
26
|
|
94
|
5
|
|
|
|
|
30
|
$self->{_list}->[$i] =~ s/${name}/${value}/g; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
|
|
8
|
return $self; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub reset { |
102
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
4
|
my @data = @{$self->{_data}}; |
|
2
|
|
|
|
|
8
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# reset hash |
107
|
2
|
|
|
|
|
6
|
my %hash = @data; |
108
|
2
|
|
|
|
|
7
|
$self->{_hash} = \%hash; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# reset list |
111
|
2
|
|
|
|
|
4
|
my @list; |
112
|
2
|
|
|
|
|
6
|
for (my $i = 0; $i < scalar(@data); $i += 2) { |
113
|
4
|
|
|
|
|
11
|
push(@list, $data[$i + 1]); |
114
|
|
|
|
|
|
|
} |
115
|
2
|
|
|
|
|
5
|
$self->{_list} = \@list; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# reset next |
118
|
2
|
|
|
|
|
5
|
$self->{_next} = 0; |
119
|
|
|
|
|
|
|
|
120
|
2
|
|
|
|
|
5
|
return $self; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _parse { |
124
|
28
|
|
|
28
|
|
53
|
my ($self, $content, $end) = @_; |
125
|
|
|
|
|
|
|
|
126
|
28
|
|
|
|
|
75
|
my @data = parse($content, $end); |
127
|
28
|
|
|
|
|
134
|
my %hash = @data; |
128
|
28
|
|
|
|
|
50
|
my %keys; |
129
|
|
|
|
|
|
|
my @list; |
130
|
|
|
|
|
|
|
|
131
|
28
|
|
|
|
|
75
|
for (my $i = 0; $i < scalar(@data); $i += 2) { |
132
|
146
|
|
|
|
|
253
|
my $name = $data[$i]; |
133
|
146
|
|
|
|
|
277
|
my @name_list = name_list($name); |
134
|
|
|
|
|
|
|
|
135
|
146
|
|
|
|
|
249
|
for (@name_list) { |
136
|
438
|
|
|
|
|
749
|
$keys{$_} = $name; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
146
|
|
|
|
|
437
|
push(@list, $data[$i + 1]); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
28
|
|
|
|
|
110
|
return (\@data, \%hash, \%keys, \@list); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |