line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Package Definition |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::CHEF; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Perl Options |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
47312
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Includes |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# Global Variables |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
use vars qw/$VERSION /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10164
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$VERSION=1.01; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Constructor Method |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
1
|
|
my ($proto)=shift; |
32
|
0
|
|
0
|
|
|
|
my ($class)=ref($proto) || $proto; |
33
|
0
|
|
|
|
|
|
my ($object)={}; |
34
|
0
|
|
|
|
|
|
bless ($object,$class); |
35
|
0
|
|
|
|
|
|
$object->_init(@_); |
36
|
0
|
|
|
|
|
|
return($object); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub read |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
42
|
0
|
|
|
|
|
|
my ($line,$key,$value,$subline,$prefix,$eoi,@input,$preline); |
43
|
0
|
|
|
|
|
|
my (@preinput)=@_; |
44
|
0
|
|
|
|
|
|
while (@preinput) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
|
$preline=shift(@preinput); |
47
|
0
|
|
|
|
|
|
push(@input,split(/\n/,$preline)); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
my (@stack); |
50
|
0
|
|
|
|
|
|
while (@input) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
|
|
|
$line=shift(@input); |
53
|
0
|
|
|
|
|
|
$line=~s/^\s+//; |
54
|
0
|
0
|
|
|
|
|
next if ($line=~/^#/); |
55
|
0
|
0
|
|
|
|
|
if ($line =~/==/) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
|
|
|
($key,$value)=split(/==/,$line); |
58
|
0
|
|
|
|
|
|
$key=_checkKey($key); |
59
|
0
|
0
|
|
|
|
|
if ($key) |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
0
|
|
|
|
|
if (@stack) |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
|
$key=$stack[$#stack].".".$key; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
0
|
|
|
|
|
if ($self->{data}->{$key}) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
|
$self->{data}->{$key}.=$value |
68
|
|
|
|
|
|
|
} else { |
69
|
0
|
|
|
|
|
|
$self->{data}->{$key}=$value; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} elsif ($line=~/=>/) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
|
($key,$eoi)=split(/=>/,$line); |
75
|
0
|
|
|
|
|
|
$key=_checkKey($key); |
76
|
0
|
|
|
|
|
|
my ($bar); |
77
|
0
|
0
|
|
|
|
|
if ($eoi =~/^\|/) |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
|
|
|
$eoi=~s/^\|//; |
80
|
0
|
|
|
|
|
|
$bar=1; |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
|
if ($key) |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
0
|
|
|
|
|
if (@stack) |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
$key=$stack[$#stack].".".$key; |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
|
$value=""; |
89
|
0
|
|
|
|
|
|
while($subline=shift(@input)) |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
|
|
|
|
$subline=~s/^\s+//; |
92
|
0
|
0
|
|
|
|
|
if ($bar) |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
|
|
|
$subline=~s/^\|//; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
0
|
|
|
|
|
if ($subline eq $eoi) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
|
$bar=0; |
99
|
0
|
|
|
|
|
|
last; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
$value.=$subline."\n"; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
0
|
|
|
|
|
if ($self->{data}->{$key}) |
104
|
|
|
|
|
|
|
{ |
105
|
0
|
|
|
|
|
|
$self->{data}->{$key}.=$value |
106
|
|
|
|
|
|
|
} else { |
107
|
0
|
|
|
|
|
|
$self->{data}->{$key}=$value; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} elsif ($line=~/=\{/) |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
|
|
|
($prefix)=split(/=\{/,$line); |
113
|
0
|
0
|
|
|
|
|
if (@stack) |
114
|
|
|
|
|
|
|
{ |
115
|
0
|
|
|
|
|
|
$prefix=$stack[$#stack].".".$prefix; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
|
push(@stack,$prefix); |
118
|
|
|
|
|
|
|
} elsif ($line eq "}") |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
|
|
|
pop(@stack); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
|
|
|
$self->_index(); |
124
|
0
|
|
|
|
|
|
return; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub readHash |
128
|
|
|
|
|
|
|
{ |
129
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
130
|
0
|
|
|
|
|
|
my (%hash)=@_; |
131
|
0
|
|
|
|
|
|
my ($k); |
132
|
0
|
|
|
|
|
|
foreach $k (CORE::keys(%hash)) |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
$self->{data}->{$k}=$hash{$k}; |
135
|
|
|
|
|
|
|
} |
136
|
0
|
|
|
|
|
|
$self->_index(); |
137
|
0
|
|
|
|
|
|
return; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub writeStream |
141
|
|
|
|
|
|
|
{ |
142
|
0
|
|
|
0
|
0
|
|
my ($self)=shift; |
143
|
0
|
|
|
|
|
|
my ($output)=""; |
144
|
0
|
|
|
|
|
|
my ($field,$eoi,@keys); |
145
|
0
|
|
|
|
|
|
(@keys)=$self->keys(); |
146
|
0
|
|
|
|
|
|
foreach $field (@keys) |
147
|
|
|
|
|
|
|
{ |
148
|
0
|
0
|
|
|
|
|
if ($self->{data}->{$field}=~/\n/) |
149
|
|
|
|
|
|
|
{ |
150
|
0
|
|
|
|
|
|
$eoi=$self->_randEOI($self->{data}->{$field}); |
151
|
0
|
|
|
|
|
|
$output.=$field."=>".$eoi."\n". |
152
|
|
|
|
|
|
|
$self->{data}->{$field}."<".$eoi; |
153
|
|
|
|
|
|
|
} else { |
154
|
0
|
|
|
|
|
|
$output.=$field."==".$self->{data}->{$field}."\n"; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
0
|
|
|
|
|
|
return($output); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub keys |
161
|
|
|
|
|
|
|
{ |
162
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
163
|
0
|
|
|
|
|
|
return(sort(CORE::keys(%{$self->{data}}))); |
|
0
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub get |
167
|
|
|
|
|
|
|
{ |
168
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
169
|
0
|
0
|
|
|
|
|
if (scalar(@_) > 1) |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
|
|
|
|
|
my ($key,%hash); |
172
|
0
|
|
|
|
|
|
foreach $key (@_) |
173
|
|
|
|
|
|
|
{ |
174
|
0
|
|
|
|
|
|
$hash{$key}=$self->{data}->{$key}; |
175
|
|
|
|
|
|
|
} |
176
|
0
|
|
|
|
|
|
return(%hash); |
177
|
|
|
|
|
|
|
} else { |
178
|
0
|
|
|
|
|
|
my ($key)=shift; |
179
|
0
|
|
|
|
|
|
return $self->{data}->{$key}; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub set |
184
|
|
|
|
|
|
|
{ |
185
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
186
|
0
|
|
|
|
|
|
my ($key,$value,$reindex); |
187
|
0
|
|
|
|
|
|
while (@_) |
188
|
|
|
|
|
|
|
{ |
189
|
0
|
|
|
|
|
|
($key,$value)=splice(@_,0,2); |
190
|
0
|
|
|
|
|
|
$key=_checkKey($key); |
191
|
0
|
0
|
|
|
|
|
if ($key) |
192
|
|
|
|
|
|
|
{ |
193
|
0
|
0
|
|
|
|
|
$reindex=1 unless ($self->{data}->{$key}); |
194
|
0
|
|
|
|
|
|
$self->{data}->{$key}=$value; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
} |
197
|
0
|
0
|
|
|
|
|
if ($reindex) |
198
|
|
|
|
|
|
|
{ |
199
|
0
|
|
|
|
|
|
$self->_index(); |
200
|
|
|
|
|
|
|
} |
201
|
0
|
|
|
|
|
|
return; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub dump |
205
|
|
|
|
|
|
|
{ |
206
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
207
|
0
|
|
|
|
|
|
return(%{$self->{data}}); |
|
0
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub copy |
211
|
|
|
|
|
|
|
{ |
212
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
213
|
0
|
|
|
|
|
|
my ($subkey)=shift; |
214
|
0
|
|
|
|
|
|
my (@list,$chef); |
215
|
0
|
|
|
|
|
|
(@list)=$self->_childKeys($subkey); |
216
|
0
|
|
|
|
|
|
$chef=$self->new(); |
217
|
0
|
|
|
|
|
|
$chef->readHash($self->get(@list)); |
218
|
0
|
|
|
|
|
|
return($chef); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub spawn |
222
|
|
|
|
|
|
|
{ |
223
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
224
|
0
|
|
|
|
|
|
my ($subkey)=shift; |
225
|
0
|
|
|
|
|
|
my ($skf,$key,$new,@list); |
226
|
0
|
|
|
|
|
|
(@list)=$self->_childKeys($subkey); |
227
|
0
|
|
|
|
|
|
$skf=ref($self)->new(); |
228
|
0
|
|
|
|
|
|
foreach $key (@list) |
229
|
|
|
|
|
|
|
{ |
230
|
0
|
|
|
|
|
|
$new=_chopKey($key,$subkey); |
231
|
0
|
|
|
|
|
|
$skf->set($new,$self->get($key)); |
232
|
|
|
|
|
|
|
} |
233
|
0
|
|
|
|
|
|
return($skf); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub spawnArray |
237
|
|
|
|
|
|
|
{ |
238
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
239
|
0
|
|
|
|
|
|
my ($subkey)=shift; |
240
|
0
|
|
|
|
|
|
my ($skf,$key,$rest,$test,$index,$new,$element,@list,@array,@processed); |
241
|
0
|
|
|
|
|
|
(@list)=$self->_childKeys($subkey); |
242
|
0
|
|
|
|
|
|
foreach $key (@list) |
243
|
|
|
|
|
|
|
{ |
244
|
0
|
|
|
|
|
|
$new=_chopKey($key,$subkey); |
245
|
0
|
|
|
|
|
|
($test,$rest)=split(/\./,$new,2); |
246
|
0
|
0
|
|
|
|
|
if ($test =~ /\((\d+)\)/) |
247
|
|
|
|
|
|
|
{ |
248
|
0
|
|
|
|
|
|
$index=$1; |
249
|
0
|
0
|
|
|
|
|
unless ($array[$index]) |
250
|
|
|
|
|
|
|
{ |
251
|
0
|
|
|
|
|
|
print("Creating index $index\n"); |
252
|
0
|
|
|
|
|
|
$array[$index]=$self->new(); |
253
|
0
|
|
|
|
|
|
$array[$index]->set("_array.index",$index); |
254
|
|
|
|
|
|
|
} |
255
|
0
|
|
|
|
|
|
$array[$index]->set($rest,$self->get($key)); |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
} |
258
|
0
|
|
|
|
|
|
foreach $element (@array) |
259
|
|
|
|
|
|
|
{ |
260
|
0
|
0
|
|
|
|
|
push(@processed,$element) if (ref($element)); |
261
|
|
|
|
|
|
|
} |
262
|
0
|
|
|
|
|
|
return(@processed); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub spawnHash |
266
|
|
|
|
|
|
|
{ |
267
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
268
|
0
|
|
|
|
|
|
my ($subkey)=shift; |
269
|
0
|
|
|
|
|
|
my ($key,$new,$test,$rest,$hkey,@list,%hash); |
270
|
0
|
|
|
|
|
|
(@list)=$self->_childKeys($subkey); |
271
|
0
|
|
|
|
|
|
foreach $key (@list) |
272
|
|
|
|
|
|
|
{ |
273
|
0
|
|
|
|
|
|
$new=_chopKey($key,$subkey); |
274
|
0
|
|
|
|
|
|
($test,$rest)=split(/\./,$new,2); |
275
|
0
|
0
|
|
|
|
|
if ($test =~ /\[(\w+)\]/) |
276
|
|
|
|
|
|
|
{ |
277
|
0
|
|
|
|
|
|
$hkey=$1; |
278
|
0
|
0
|
|
|
|
|
unless ($hash{$hkey}) |
279
|
|
|
|
|
|
|
{ |
280
|
0
|
|
|
|
|
|
$hash{$hkey}=$self->new(); |
281
|
0
|
|
|
|
|
|
$hash{$hkey}->set("_array.hash",$hkey); |
282
|
|
|
|
|
|
|
} |
283
|
0
|
|
|
|
|
|
$hash{$hkey}->set($rest,$self->get($key)); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
} |
286
|
0
|
|
|
|
|
|
return (%hash); |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub current |
290
|
|
|
|
|
|
|
{ |
291
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
292
|
0
|
|
|
|
|
|
my ($pos); |
293
|
0
|
|
|
|
|
|
$pos=$self->{index}->[$self->{ptr}]; |
294
|
0
|
|
|
|
|
|
return($pos,$self->{data}->{$pos}); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub next |
298
|
|
|
|
|
|
|
{ |
299
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
300
|
0
|
0
|
|
|
|
|
unless ($self->{ptr}==$#{$self->{index}}) |
|
0
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
{ |
302
|
0
|
|
|
|
|
|
$self->{ptr}++; |
303
|
|
|
|
|
|
|
} |
304
|
0
|
|
|
|
|
|
return; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub prev |
308
|
|
|
|
|
|
|
{ |
309
|
0
|
|
|
0
|
1
|
|
my ($self)=shift; |
310
|
0
|
0
|
|
|
|
|
unless ($self->{ptr}==0) |
311
|
|
|
|
|
|
|
{ |
312
|
0
|
|
|
|
|
|
$self->{ptr}--; |
313
|
|
|
|
|
|
|
} |
314
|
0
|
|
|
|
|
|
return; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
# |
318
|
|
|
|
|
|
|
# Hidden Methods |
319
|
|
|
|
|
|
|
# |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub _init |
322
|
|
|
|
|
|
|
{ |
323
|
0
|
|
|
0
|
|
|
my ($self)=shift; |
324
|
0
|
|
|
|
|
|
return; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
# |
328
|
|
|
|
|
|
|
# Initialize the data pointer to zero |
329
|
|
|
|
|
|
|
# Recalculate the maximum size of the ptr |
330
|
|
|
|
|
|
|
sub _index |
331
|
|
|
|
|
|
|
{ |
332
|
0
|
|
|
0
|
|
|
my ($self)=shift; |
333
|
0
|
|
|
|
|
|
my (@keys); |
334
|
0
|
|
|
|
|
|
(@keys)=sort(CORE::keys(%{$self->{data}})); |
|
0
|
|
|
|
|
|
|
335
|
0
|
|
|
|
|
|
$self->{index}=[ @keys ]; |
336
|
0
|
|
|
|
|
|
$self->{ptr}=0; |
337
|
0
|
|
|
|
|
|
return; |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# |
341
|
|
|
|
|
|
|
# Create a random end of input string |
342
|
|
|
|
|
|
|
# for writing multiline values |
343
|
|
|
|
|
|
|
# double check to make sure marker isn't identical to value |
344
|
|
|
|
|
|
|
sub _randEOI |
345
|
|
|
|
|
|
|
{ |
346
|
0
|
|
|
0
|
|
|
my ($self)=shift; |
347
|
0
|
|
|
|
|
|
my ($value)=shift; |
348
|
0
|
|
|
|
|
|
my ($eoi,$count); |
349
|
0
|
|
|
|
|
|
do { |
350
|
0
|
|
|
|
|
|
$count=2; |
351
|
0
|
|
|
|
|
|
$eoi=""; |
352
|
0
|
|
|
|
|
|
while ($count) |
353
|
|
|
|
|
|
|
{ |
354
|
0
|
|
|
|
|
|
$eoi.=chr(int(rand(26))+97); |
355
|
0
|
|
|
|
|
|
$count--; |
356
|
|
|
|
|
|
|
} |
357
|
0
|
|
|
|
|
|
$count=3; |
358
|
0
|
|
|
|
|
|
while ($count) |
359
|
|
|
|
|
|
|
{ |
360
|
0
|
|
|
|
|
|
$eoi.=int(rand(10)); |
361
|
0
|
|
|
|
|
|
$count--; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
} until ($eoi ne $value); |
364
|
0
|
|
|
|
|
|
return($eoi); |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
# |
368
|
|
|
|
|
|
|
# Check the key to make sure it's valid |
369
|
|
|
|
|
|
|
sub _checkKey |
370
|
|
|
|
|
|
|
{ |
371
|
0
|
|
|
0
|
|
|
my ($key)=shift; |
372
|
0
|
|
|
|
|
|
$key=lc($key); |
373
|
0
|
0
|
|
|
|
|
if ($key=~/^([\w\-]+|\(\d+\)|\[[\w\-]+\])(\.([\w\-]+|\(\d+\)|\[[\w\-]+\]))*$/) |
374
|
|
|
|
|
|
|
{ |
375
|
0
|
|
|
|
|
|
return $key; |
376
|
|
|
|
|
|
|
} else { |
377
|
0
|
|
|
|
|
|
print("Invalid key ($key)\n"); |
378
|
0
|
|
|
|
|
|
return undef; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub _childKeys |
383
|
|
|
|
|
|
|
{ |
384
|
0
|
|
|
0
|
|
|
my ($self)=shift; |
385
|
0
|
|
|
|
|
|
my ($substr)=shift; |
386
|
0
|
|
|
|
|
|
$substr="^".quotemeta($substr); |
387
|
0
|
|
|
|
|
|
my ($k,@list); |
388
|
0
|
|
|
|
|
|
foreach $k ($self->keys()) |
389
|
|
|
|
|
|
|
{ |
390
|
0
|
0
|
|
|
|
|
if ($k =~ /$substr/) |
391
|
|
|
|
|
|
|
{ |
392
|
0
|
|
|
|
|
|
push(@list,$k); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
} |
395
|
0
|
|
|
|
|
|
return(@list); |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub _chopKey |
399
|
|
|
|
|
|
|
{ |
400
|
0
|
|
|
0
|
|
|
my ($key,$parent)=@_; |
401
|
0
|
|
|
|
|
|
my ($child); |
402
|
0
|
|
|
|
|
|
$parent="^".quotemeta($parent."."); |
403
|
0
|
|
|
|
|
|
$child=$key; |
404
|
0
|
|
|
|
|
|
$child=~s/$parent//; |
405
|
0
|
|
|
|
|
|
return($child); |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# |
409
|
|
|
|
|
|
|
# Special version of set |
410
|
|
|
|
|
|
|
# Allows uppercase characters in keys |
411
|
|
|
|
|
|
|
sub _set |
412
|
|
|
|
|
|
|
{ |
413
|
0
|
|
|
0
|
|
|
my ($self)=shift; |
414
|
0
|
|
|
|
|
|
my ($key,$value,$reindex); |
415
|
0
|
|
|
|
|
|
while (@_) |
416
|
|
|
|
|
|
|
{ |
417
|
0
|
|
|
|
|
|
($key,$value)=splice(@_,0,2); |
418
|
0
|
0
|
|
|
|
|
if ($key) |
419
|
|
|
|
|
|
|
{ |
420
|
0
|
0
|
|
|
|
|
$reindex=1 unless ($self->{data}->{$key}); |
421
|
0
|
|
|
|
|
|
$self->{data}->{$key}=$value; |
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
} |
424
|
0
|
0
|
|
|
|
|
if ($reindex) |
425
|
|
|
|
|
|
|
{ |
426
|
0
|
|
|
|
|
|
$self->_index(); |
427
|
|
|
|
|
|
|
} |
428
|
0
|
|
|
|
|
|
return; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
# |
432
|
|
|
|
|
|
|
# Exit Block |
433
|
|
|
|
|
|
|
# |
434
|
|
|
|
|
|
|
1; |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
__END__ |