line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: Encode.pm |
3
|
|
|
|
|
|
|
## Purpose: HDB::Encode - Common things for HDB modules. |
4
|
|
|
|
|
|
|
## Author: Graciliano M. P. |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 15/01/2003 |
7
|
|
|
|
|
|
|
## RCS-ID: |
8
|
|
|
|
|
|
|
## Copyright: (c) 2002 Graciliano M. P. |
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
11
|
|
|
|
|
|
|
############################################################################# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package HDB::Encode ; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
8
|
use strict qw(vars); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
16
|
1
|
|
|
1
|
|
7
|
no warnings ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5599
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.0' ; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
######## |
21
|
|
|
|
|
|
|
# VARS # |
22
|
|
|
|
|
|
|
######## |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %VER = ( |
25
|
|
|
|
|
|
|
PACKED_HASH => '1.0' , |
26
|
|
|
|
|
|
|
PACKED_ARRAY => '1.0' , |
27
|
|
|
|
|
|
|
) ; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
######## |
30
|
|
|
|
|
|
|
# PACK # |
31
|
|
|
|
|
|
|
######## |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Pack { |
34
|
0
|
0
|
|
0
|
1
|
|
if ( ref($_[0]) eq 'HASH' ) { return &Pack_HASH($_[0]) ;} |
|
0
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ( ref($_[0]) eq 'ARRAY' ) { return &Pack_ARRAY($_[0]) ;} |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
############# |
39
|
|
|
|
|
|
|
# PACK_HASH # |
40
|
|
|
|
|
|
|
############# |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub Pack_HASH { |
43
|
0
|
|
|
0
|
1
|
|
my ( $hash ) = @_ ; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if (ref($hash) ne 'HASH') { return( undef ) ;} |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my ($pack_init,$pack) ; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$pack_init = "%HDB_PACKED_HASH%[$VER{PACKED_HASH}]{0}:" if !$_[1] ; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $key ( keys %$hash ) { |
52
|
0
|
|
|
|
|
|
my ($blk,$tp,$value) ; |
53
|
0
|
0
|
|
|
|
|
if ( ref( $$hash{$key} ) eq 'HASH' ) { $tp = 1 ; $value = &Pack_HASH( $$hash{$key} , 1 ) } |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
elsif ( ref( $$hash{$key} ) eq 'ARRAY' ) { $tp = 2 ; $value = &Pack_ARRAY( $$hash{$key} , 1 ) ;} |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($$hash{$key} ,'UNIVERSAL') ) { next ;} ## ignore objects. |
56
|
0
|
|
|
|
|
|
else { $tp = 0 ; $value = $$hash{$key} ;} |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$blk .= $tp ; |
59
|
0
|
|
|
|
|
|
$blk .= length($key) . ":" ; |
60
|
0
|
|
|
|
|
|
$blk .= $key ; |
61
|
0
|
|
|
|
|
|
$blk .= length($value) . ":" ; |
62
|
0
|
|
|
|
|
|
$blk .= $value ; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$pack .= $blk ; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { |
68
|
0
|
|
|
|
|
|
my $sz = length($pack) ; |
69
|
0
|
|
|
|
|
|
$pack_init =~ s/\{0}/\{$sz}/s ; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return( $pack_init . $pack ) ; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
############## |
76
|
|
|
|
|
|
|
# PACK_ARRAY # |
77
|
|
|
|
|
|
|
############## |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub Pack_ARRAY { |
80
|
0
|
|
|
0
|
1
|
|
my ( $array ) = @_ ; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if (ref($array) ne 'ARRAY') { return( undef ) ;} |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my ($pack_init,$pack) ; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
$pack_init = "%HDB_PACKED_ARRAY%[$VER{PACKED_ARRAY}]{0}:" if !$_[1] ; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
foreach my $array_i ( @$array ) { |
89
|
0
|
|
|
|
|
|
my ($blk,$tp,$value) ; |
90
|
0
|
0
|
|
|
|
|
if ( ref( $array_i ) eq 'HASH' ) { $tp = 1 ; $value = &Pack_HASH( $array_i , 1 ) ;} |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
elsif ( ref( $array_i ) eq 'ARRAY' ) { $tp = 2 ; $value = &Pack_ARRAY( $array_i , 1 ) ;} |
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($array_i ,'UNIVERSAL') ) { next ;} ## ignore objects. |
93
|
0
|
|
|
|
|
|
else { $tp = 0 ; $value = $array_i ;} |
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$blk .= $tp ; |
96
|
0
|
|
|
|
|
|
$blk .= length($value) . ":" ; |
97
|
0
|
|
|
|
|
|
$blk .= $value ; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
$pack .= $blk ; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { |
103
|
0
|
|
|
|
|
|
my $sz = length($pack) ; |
104
|
0
|
|
|
|
|
|
$pack_init =~ s/\{0}/\{$sz}/s ; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return( $pack_init . $pack ) ; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
########## |
111
|
|
|
|
|
|
|
# UNPACK # |
112
|
|
|
|
|
|
|
########## |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub UnPack { |
115
|
0
|
0
|
|
0
|
1
|
|
if ( &Is_Packed_HASH($_[0]) ) { return &UnPack_HASH($_[0]) ;} |
|
0
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
if ( &Is_Packed_ARRAY($_[0]) ) { return &UnPack_ARRAY($_[0]) ;} |
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return( $_[0] ) ; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
############### |
121
|
|
|
|
|
|
|
# UNPACK_HASH # |
122
|
|
|
|
|
|
|
############### |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub UnPack_HASH { |
125
|
0
|
|
|
0
|
1
|
|
my %hash ; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $pos = 0 ; |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { |
130
|
0
|
0
|
|
|
|
|
if ( !&Is_Packed_HASH($_[0]) ) { return() ;} |
|
0
|
0
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
elsif ( !&Check_Pack_Size($_[0]) ) { return("SIZE_ERROR: $_[0]") ;} |
132
|
0
|
|
|
|
|
|
else { $pos = index($_[0],':') + 1 ;} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $lng = length($_[0]) ; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
while( $pos < $lng ) { |
138
|
0
|
|
|
|
|
|
my $tp = substr($_[0],$pos++,1) ; |
139
|
0
|
|
|
|
|
|
my $key = &blk_read($_[0],$pos) ; |
140
|
0
|
|
|
|
|
|
my $val = &blk_read($_[0],$pos) ; |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
|
|
|
|
if ($tp == 1) { |
|
|
0
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my %val = &UnPack_HASH($val,1) ; |
144
|
0
|
|
|
|
|
|
$val = \%val ; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
elsif ($tp == 2) { |
147
|
0
|
|
|
|
|
|
my @val = &UnPack_ARRAY($val,1) ; |
148
|
0
|
|
|
|
|
|
$val = \@val ; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
$hash{$key} = $val ; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if ( wantarray ) { return( %hash ) ;} |
|
0
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
else { return( \%hash ) ;} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
################ |
159
|
|
|
|
|
|
|
# UNPACK_ARRAY # |
160
|
|
|
|
|
|
|
################ |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub UnPack_ARRAY { |
163
|
0
|
|
|
0
|
1
|
|
my @array ; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $pos = 0 ; |
166
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { |
168
|
0
|
0
|
|
|
|
|
if ( !&Is_Packed_ARRAY($_[0]) ) { return() ;} |
|
0
|
0
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
elsif ( !&Check_Pack_Size($_[0]) ) { return("SIZE_ERROR: $_[0]") ;} |
170
|
0
|
|
|
|
|
|
else { $pos = index($_[0],':') + 1 ;} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
my $lng = length($_[0]) ; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
while( $pos < $lng ) { |
176
|
0
|
|
|
|
|
|
my $tp = substr($_[0],$pos++,1) ; |
177
|
0
|
|
|
|
|
|
my $val = &blk_read($_[0],$pos) ; |
178
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if ($tp == 1) { |
|
|
0
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my %val = &UnPack_HASH($val,1) ; |
181
|
0
|
|
|
|
|
|
$val = \%val ; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
elsif ($tp == 2) { |
184
|
0
|
|
|
|
|
|
my @val = &UnPack_ARRAY($val,1) ; |
185
|
0
|
|
|
|
|
|
$val = \@val ; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
push(@array , $val) ; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
0
|
0
|
|
|
|
|
if ( wantarray ) { return( @array ) ;} |
|
0
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
else { return( \@array ) ;} |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
############ |
196
|
|
|
|
|
|
|
# BLK_READ # |
197
|
|
|
|
|
|
|
############ |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub blk_read { |
200
|
0
|
|
|
0
|
0
|
|
my ( undef , undef , $lng ) = @_ ; |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
if (!$lng) { $lng = length( $_[0] ) ;} |
|
0
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
my ($s,$sz) ; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
while( $_[1] <= $lng ) { |
207
|
0
|
|
|
|
|
|
$s = substr( $_[0] , $_[1] , 1) ; |
208
|
0
|
|
|
|
|
|
$_[1]++ ; |
209
|
0
|
0
|
|
|
|
|
if ($s eq ':') { last ;} |
|
0
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
$sz .= $s ; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
my $blk = substr( $_[0] , $_[1] , $sz) ; |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
$_[1] += $sz ; |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
return( $blk ) ; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
################## |
221
|
|
|
|
|
|
|
# IS_PACKED_HASH # |
222
|
|
|
|
|
|
|
################## |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub Is_Packed_HASH { |
225
|
0
|
0
|
|
0
|
1
|
|
if ( $_[0] =~ /^\s*\%HDB_PACKED_HASH%\[[\d\.]+]\{\d+}:/ ) { return( 1 ) ;} |
|
0
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
return( undef ) ; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
################### |
230
|
|
|
|
|
|
|
# IS_PACKED_ARRAY # |
231
|
|
|
|
|
|
|
################### |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub Is_Packed_ARRAY { |
234
|
0
|
0
|
|
0
|
1
|
|
if ( $_[0] =~ /^\s*\%HDB_PACKED_ARRAY%\[[\d\.]+]\{\d+}:/ ) { return( 1 ) ;} |
|
0
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
return( undef ) ; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
################### |
239
|
|
|
|
|
|
|
# CHECK_PACK_SIZE # |
240
|
|
|
|
|
|
|
################### |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub Check_Pack_Size { |
243
|
0
|
0
|
|
0
|
1
|
|
if ( $_[0] =~ /^(\s*\%HDB_PACKED_(?:HASH|ARRAY)%\[[\d\.]+]\{)(\d+)(}:)/s ) { |
244
|
0
|
|
|
|
|
|
my $lng = length($1) + length($3) ; |
245
|
0
|
|
|
|
|
|
my $sz = $2 ; |
246
|
0
|
|
|
|
|
|
$lng += length($sz) + $sz ; |
247
|
0
|
0
|
|
|
|
|
if ( length($_[0]) == $lng ) { return( 1 ) ;} |
|
0
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
} |
249
|
0
|
|
|
|
|
|
return( undef ) ; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
############### |
253
|
|
|
|
|
|
|
# PACKED_SIZE # |
254
|
|
|
|
|
|
|
############### |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub Packed_SIZE { |
257
|
0
|
|
|
0
|
1
|
|
my ( $ref ) = @_ ; |
258
|
0
|
0
|
|
|
|
|
if ( ref($ref) eq 'HASH' ) { return &Packed_SIZE_HASH($ref) ;} |
|
0
|
|
|
|
|
|
|
259
|
0
|
0
|
|
|
|
|
if ( ref($ref) eq 'ARRAY' ) { return &Packed_SIZE_ARRAY($ref) ;} |
|
0
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
#################### |
263
|
|
|
|
|
|
|
# PACKED_SIZE_HASH # |
264
|
|
|
|
|
|
|
#################### |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub Packed_SIZE_HASH { |
267
|
0
|
|
|
0
|
1
|
|
my ( $hash ) = @_ ; |
268
|
|
|
|
|
|
|
|
269
|
0
|
0
|
|
|
|
|
if (ref($hash) ne 'HASH') { return( undef ) ;} |
|
0
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
my ($pack_init,$size) ; |
272
|
|
|
|
|
|
|
|
273
|
0
|
0
|
|
|
|
|
$pack_init = "%HDB_PACKED_HASH%[$VER{PACKED_HASH}]{0}:" if !$_[1] ; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
foreach my $key ( keys %$hash ) { |
276
|
0
|
|
|
|
|
|
my ($blk_sz,$value_sz) ; |
277
|
0
|
0
|
|
|
|
|
if ( ref( $$hash{$key} ) eq 'HASH' ) { $value_sz = &Packed_SIZE_HASH( $$hash{$key} , 1 ) } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
elsif ( ref( $$hash{$key} ) eq 'ARRAY' ) { $value_sz = &Packed_SIZE_ARRAY( $$hash{$key} , 1 ) ;} |
279
|
0
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($$hash{$key} ,'UNIVERSAL') ) { next ;} ## ignore objects. |
280
|
0
|
|
|
|
|
|
else { $value_sz = length( $$hash{$key} ) ;} |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
$blk_sz += 1 ; |
283
|
0
|
|
|
|
|
|
$blk_sz += length(length($key)) + 1 ; |
284
|
0
|
|
|
|
|
|
$blk_sz += length($key) ; |
285
|
0
|
|
|
|
|
|
$blk_sz += length($value_sz) + 1 ; |
286
|
0
|
|
|
|
|
|
$blk_sz += $value_sz ; |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
$size += $blk_sz ; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { $pack_init =~ s/\{0}/\{$size}/s ;} |
|
0
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
293
|
0
|
0
|
|
|
|
|
$size += length($pack_init) if !$_[1] ; |
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
return( $size ) ; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
##################### |
299
|
|
|
|
|
|
|
# PACKED_SIZE_ARRAY # |
300
|
|
|
|
|
|
|
##################### |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub Packed_SIZE_ARRAY { |
303
|
0
|
|
|
0
|
1
|
|
my ( $array ) = @_ ; |
304
|
|
|
|
|
|
|
|
305
|
0
|
0
|
|
|
|
|
if (ref($array) ne 'ARRAY') { return( undef ) ;} |
|
0
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
my ($pack_init,$size) ; |
308
|
|
|
|
|
|
|
|
309
|
0
|
0
|
|
|
|
|
$pack_init = "%HDB_PACKED_ARRAY%[$VER{PACKED_ARRAY}]{0}:" if !$_[1] ; |
310
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
|
foreach my $array_i ( @$array ) { |
312
|
0
|
|
|
|
|
|
my ($blk_sz,$value_sz) ; |
313
|
0
|
0
|
|
|
|
|
if ( ref( $array_i ) eq 'HASH' ) { $value_sz = &Packed_SIZE_HASH( $array_i , 1 ) ;} |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
elsif ( ref( $array_i ) eq 'ARRAY' ) { $value_sz = &Packed_SIZE_ARRAY( $array_i , 1 ) ;} |
315
|
0
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($array_i ,'UNIVERSAL') ) { next ;} ## ignore objects. |
316
|
0
|
|
|
|
|
|
else { $value_sz = length($array_i) ;} |
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
$blk_sz += 1 ; |
319
|
0
|
|
|
|
|
|
$blk_sz += length($value_sz) + 1 ; |
320
|
0
|
|
|
|
|
|
$blk_sz += $value_sz ; |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
$size += $blk_sz ; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
0
|
0
|
|
|
|
|
if ( !$_[1] ) { $pack_init =~ s/\{0}/\{$size}/s ;} |
|
0
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
|
327
|
0
|
0
|
|
|
|
|
$size += length($pack_init) if !$_[1] ; |
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
return( $size ) ; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
####### |
333
|
|
|
|
|
|
|
# END # |
334
|
|
|
|
|
|
|
####### |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# 0 => key & val || line |
337
|
|
|
|
|
|
|
# 1 => hash ref |
338
|
|
|
|
|
|
|
# 2 => array ref |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
1; |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
__END__ |