|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Data::Check::Structure;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $DATE = '2020-11-08'; # DATE  | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $DIST = 'Data-Check-Structure'; # DIST  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '0.050'; # VERSION  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
68284
 | 
 use strict;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
33
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #use warnings;  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
5
 | 
 use Exporter 'import';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1532
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT_OK = qw(  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_aoa  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_aoaos  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_aoh  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_aohos  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_aos  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_hoa  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_hoaos  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_hoh  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_hohos  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                        is_hos  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                );  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $errstr = '';  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_aos {  | 
| 
28
 | 
15
 | 
 
 | 
 
 | 
  
15
  
 | 
  
1
  
 | 
1230
 | 
     my ($data, $opts) = @_;  | 
| 
29
 | 
15
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
49
 | 
     $opts ||= {};  | 
| 
30
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
39
 | 
     my $max = $opts->{max};  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
15
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
38
 | 
     return 0 unless ref($data) eq 'ARRAY';  | 
| 
33
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32
 | 
     for my $i (0..@$data-1) {  | 
| 
34
 | 
15
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
42
 | 
         last if defined($max) && $i >= $max;  | 
| 
35
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26
 | 
         my $ref = ref($data->[$i]);  | 
| 
36
 | 
14
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
32
 | 
         do { $errstr = "not aos: array element [$i] not scalar ($ref)"; return 0 } if $ref;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
38
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     $errstr = '';  | 
| 
39
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
     1;  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_aoa {  | 
| 
43
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
1
  
 | 
2384
 | 
     my ($data, $opts) = @_;  | 
| 
44
 | 
4
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
20
 | 
     $opts ||= {};  | 
| 
45
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my $max = $opts->{max};  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     return 0 unless ref($data) eq 'ARRAY';  | 
| 
48
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     for my $i (0..@$data-1) {  | 
| 
49
 | 
8
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
26
 | 
         last if defined($max) && $i >= $max;  | 
| 
50
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
         my $ref = ref($data->[$i]);  | 
| 
51
 | 
7
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
20
 | 
         do { $errstr = "not aoa: array element [$i] not array ($ref)"; return 0 } unless $ref eq 'ARRAY';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
53
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $errstr = '';  | 
| 
54
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     1;  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_aoaos {  | 
| 
58
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
1
  
 | 
2192
 | 
     my ($data, $opts) = @_;  | 
| 
59
 | 
4
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
21
 | 
     $opts ||= {};  | 
| 
60
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my $max = $opts->{max};  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
62
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     return 0 unless ref($data) eq 'ARRAY';  | 
| 
63
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my $aos_opts = {max=>$max};  | 
| 
64
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     for my $i (0..@$data-1) {  | 
| 
65
 | 
8
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
56
 | 
         last if defined($max) && $i >= $max;  | 
| 
66
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
         do { $errstr = "not aoaos: element [$i]".($errstr ? ": $errstr" : " not aos"); return 0 } unless is_aos($data->[$i], $aos_opts);  | 
| 
 
 | 
1
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
68
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     $errstr = '';  | 
| 
69
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     1;  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_aoh {  | 
| 
73
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
1
  
 | 
2192
 | 
     my ($data, $opts) = @_;  | 
| 
74
 | 
4
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
22
 | 
     $opts ||= {};  | 
| 
75
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     my $max = $opts->{max};  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     return 0 unless ref($data) eq 'ARRAY';  | 
| 
78
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     for my $i (0..@$data-1) {  | 
| 
79
 | 
8
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
26
 | 
         last if defined($max) && $i >= $max;  | 
| 
80
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
         my $ref = ref($data->[$i]);  | 
| 
81
 | 
7
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
17
 | 
         do { $errstr = "not aoh: element [$i] not hash ($ref)"; return 0 } unless $ref eq 'HASH';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
83
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     $errstr = '';  | 
| 
84
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     1;  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_aohos {  | 
| 
88
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
1
  
 | 
2269
 | 
     my ($data, $opts) = @_;  | 
| 
89
 | 
4
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
19
 | 
     $opts ||= {};  | 
| 
90
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     my $max = $opts->{max};  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
92
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     return 0 unless ref($data) eq 'ARRAY';  | 
| 
93
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my $hos_opts = {max=>$max};  | 
| 
94
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     for my $i (0..@$data-1) {  | 
| 
95
 | 
8
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
28
 | 
         last if defined($max) && $i >= $max;  | 
| 
96
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
         do { $errstr = "not aohos: element [$i]".($errstr ? ": $errstr" : " not hos"); return 0 } unless is_hos($data->[$i], $hos_opts);  | 
| 
 
 | 
1
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
98
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $errstr = '';  | 
| 
99
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     1;  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
102
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_hos {  | 
| 
103
 | 
14
 | 
 
 | 
 
 | 
  
14
  
 | 
  
1
  
 | 
2274
 | 
     my ($data, $opts) = @_;  | 
| 
104
 | 
14
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
46
 | 
     $opts ||= {};  | 
| 
105
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
     my $max = $opts->{max};  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
107
 | 
14
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
35
 | 
     return 0 unless ref($data) eq 'HASH';  | 
| 
108
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
     my $i = 0;  | 
| 
109
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
     for my $k (keys %$data) {  | 
| 
110
 | 
9
 | 
  
 50
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
25
 | 
         last if defined($max) && ++$i >= $max;  | 
| 
111
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
         my $ref = ref($data->{$k});  | 
| 
112
 | 
9
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
20
 | 
         do { $errstr = "not hos: value for key '$k' not scalar ($ref)"; return 0 } if $ref;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
114
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
     $errstr = '';  | 
| 
115
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
     1;  | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
118
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_hoa {  | 
| 
119
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
2221
 | 
     my ($data, $opts) = @_;  | 
| 
120
 | 
3
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
18
 | 
     $opts ||= {};  | 
| 
121
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     my $max = $opts->{max};  | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
123
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     return 0 unless ref($data) eq 'HASH';  | 
| 
124
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     my $i = 0;  | 
| 
125
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     for my $k (keys %$data) {  | 
| 
126
 | 
2
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
6
 | 
         last if defined($max) && ++$i >= $max;  | 
| 
127
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
         my $ref = ref($data->{$k});  | 
| 
128
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
         do { $errstr = "not hoa: value for key '$k' not array ($ref)"; return 0 } unless $ref eq 'ARRAY';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
129
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
130
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $errstr = '';  | 
| 
131
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     1;  | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
134
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_hoaos {  | 
| 
135
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
  
1
  
 | 
2185
 | 
     my ($data, $opts) = @_;  | 
| 
136
 | 
5
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
26
 | 
     $opts ||= {};  | 
| 
137
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
     my $max = $opts->{max};  | 
| 
138
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
139
 | 
5
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     return 0 unless ref($data) eq 'HASH';  | 
| 
140
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my $i = 0;  | 
| 
141
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     for my $k (keys %$data) {  | 
| 
142
 | 
4
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
12
 | 
         last if defined($max) && ++$i >= $max;  | 
| 
143
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
         do { $errstr = "not hoaos: value for key '$k'".($errstr ? ": $errstr" : " not aos"); return 0 } unless is_aos($data->{$k});  | 
| 
 
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
144
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
145
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $errstr = '';  | 
| 
146
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
     1;  | 
| 
147
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
148
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
149
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_hoh {  | 
| 
150
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
2207
 | 
     my ($data, $opts) = @_;  | 
| 
151
 | 
3
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
33
 | 
     $opts ||= {};  | 
| 
152
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     my $max = $opts->{max};  | 
| 
153
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
154
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     return 0 unless ref($data) eq 'HASH';  | 
| 
155
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     my $i = 0;  | 
| 
156
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     for my $k (keys %$data) {  | 
| 
157
 | 
2
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
7
 | 
         last if defined($max) && ++$i >= $max;  | 
| 
158
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
         my $ref = ref($data->{$k});  | 
| 
159
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
         do { $errstr = "not hoh: value for key '$k' not hash ($ref)"; return 0 } unless $ref eq 'HASH';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
160
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
161
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $errstr = '';  | 
| 
162
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     1;  | 
| 
163
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
164
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
165
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_hohos {  | 
| 
166
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
  
1
  
 | 
2246
 | 
     my ($data, $opts) = @_;  | 
| 
167
 | 
5
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
26
 | 
     $opts ||= {};  | 
| 
168
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     my $max = $opts->{max};  | 
| 
169
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
170
 | 
5
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
     return 0 unless ref($data) eq 'HASH';  | 
| 
171
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     my $i = 0;  | 
| 
172
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     for my $k (keys %$data) {  | 
| 
173
 | 
4
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
13
 | 
         last if defined($max) && ++$i >= $max;  | 
| 
174
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
         do { $errstr = "not hohos: value for key '$k'".($errstr ? ": $errstr" : " not hos"); return 0 } unless is_hos($data->{$k});  | 
| 
 
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
175
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
176
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $errstr = '';  | 
| 
177
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     1;  | 
| 
178
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
179
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
180
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
181
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Check structure of data  | 
| 
182
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
183
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |