| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Config::XrmDatabase::Util; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Constants that won't change, and other utilitarian things. |
|
4
|
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
287515
|
use v5.26; |
|
|
10
|
|
|
|
|
38
|
|
|
6
|
10
|
|
|
10
|
|
56
|
use warnings; |
|
|
10
|
|
|
|
|
20
|
|
|
|
10
|
|
|
|
|
806
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
634
|
use Config::XrmDatabase::Failure ':all'; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
1562
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
10
|
|
|
10
|
|
5658
|
use namespace::clean; |
|
|
10
|
|
|
|
|
204542
|
|
|
|
10
|
|
|
|
|
75
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
10
|
|
|
10
|
|
3207
|
use Exporter 'import'; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
427
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
10
|
|
|
10
|
|
5520
|
use experimental qw( signatures postderef ); |
|
|
10
|
|
|
|
|
42870
|
|
|
|
10
|
|
|
|
|
66
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %CONSTANTS; |
|
19
|
|
|
|
|
|
|
our ( %META, %RMETA ); # these get exported |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
BEGIN { |
|
22
|
10
|
|
|
10
|
|
5924
|
%CONSTANTS = ( |
|
23
|
|
|
|
|
|
|
TIGHT => q{.}, |
|
24
|
|
|
|
|
|
|
SINGLE => q{?}, |
|
25
|
|
|
|
|
|
|
LOOSE => q{*}, |
|
26
|
|
|
|
|
|
|
VALUE => '!!VALUE', |
|
27
|
|
|
|
|
|
|
MATCH_COUNT => '!!MATCH_COUNT', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
%META = ( |
|
31
|
|
|
|
|
|
|
$CONSTANTS{VALUE} => 'value', |
|
32
|
10
|
|
|
|
|
73
|
$CONSTANTS{MATCH_COUNT} => 'match_count', |
|
33
|
|
|
|
|
|
|
); |
|
34
|
10
|
|
|
|
|
58
|
%RMETA = reverse %META; |
|
35
|
|
|
|
|
|
|
|
|
36
|
10
|
|
|
|
|
19
|
$CONSTANTS{META_QR} = qr/@{[ join '|', map { quotemeta } keys %META ]}/i; |
|
|
10
|
|
|
|
|
38
|
|
|
|
20
|
|
|
|
|
1414
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# so we can use the scalars here without complaints |
|
40
|
10
|
|
|
10
|
|
108
|
use vars map { q{$} . $_ } keys %CONSTANTS; |
|
|
10
|
|
|
|
|
24
|
|
|
|
10
|
|
|
|
|
39
|
|
|
|
60
|
|
|
|
|
1339
|
|
|
41
|
|
|
|
|
|
|
{ |
|
42
|
10
|
|
|
10
|
|
78
|
no strict 'refs'; ## no critic(ProhibitNoStrict) |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
1103
|
|
|
43
|
|
|
|
|
|
|
*{$_} = \( $CONSTANTS{$_} ) for keys %CONSTANTS; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
10
|
|
|
10
|
|
68
|
use constant \%CONSTANTS; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
10857
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
49
|
|
|
|
|
|
|
scalar => [ map "\$$_", keys( %CONSTANTS ) ], |
|
50
|
|
|
|
|
|
|
constants => [ keys( %CONSTANTS ) ], |
|
51
|
|
|
|
|
|
|
hashes => [qw( %META %RMETA )], |
|
52
|
|
|
|
|
|
|
funcs => [ |
|
53
|
|
|
|
|
|
|
qw( parse_resource_name parse_fq_resource_name |
|
54
|
|
|
|
|
|
|
normalize_key name_arr_to_str is_wildcard ), |
|
55
|
|
|
|
|
|
|
], |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our @EXPORT_OK = ( map { @$_ } values %EXPORT_TAGS ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$EXPORT_TAGS{all} = \@EXPORT_OK; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
1602
|
|
|
1602
|
1
|
278051
|
sub parse_resource_name ( $name ) { |
|
|
1602
|
|
|
|
|
2781
|
|
|
|
1602
|
|
|
|
|
2399
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{ |
|
76
|
|
|
|
|
|
|
## no critic (AmbiguousNames) |
|
77
|
1602
|
|
|
|
|
2503
|
my $last = substr( $name, -1 ); |
|
|
1602
|
|
|
|
|
3598
|
|
|
78
|
1602
|
100
|
100
|
|
|
8542
|
key_failure->throw( "last component of name may not be a binding operator: $name" ) |
|
|
|
|
100
|
|
|
|
|
|
79
|
|
|
|
|
|
|
if $last eq TIGHT || $last eq SINGLE || $last eq LOOSE; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# all consecutive '.' characters are replaced with a single one. |
|
83
|
1599
|
|
|
|
|
15548
|
$name =~ s/[$TIGHT]+/$TIGHT/g; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# any combination of '.' and '*' is replaced with a '*' |
|
86
|
1599
|
|
|
|
|
7672
|
$name =~ s/[${TIGHT}${LOOSE}]{2,}/$LOOSE/g; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# toss out fields: |
|
89
|
|
|
|
|
|
|
# - the tight binding operator; that is the default. |
|
90
|
|
|
|
|
|
|
# - empty fields correspond to two sequential binding operators |
|
91
|
|
|
|
|
|
|
# or a leading binding operator |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return [ |
|
94
|
1599
|
100
|
|
|
|
14660
|
grep { $_ ne TIGHT && $_ ne q{} } |
|
|
23043
|
|
|
|
|
75803
|
|
|
95
|
|
|
|
|
|
|
split( /([${TIGHT}${SINGLE}${LOOSE}])/, $name ) ]; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
45
|
|
|
45
|
1
|
17705
|
sub parse_fq_resource_name ( $name ) { |
|
|
45
|
|
|
|
|
90
|
|
|
|
45
|
|
|
|
|
73
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
45
|
100
|
100
|
|
|
247
|
key_failure->throw( |
|
111
|
|
|
|
|
|
|
"cannot have '$LOOSE' or '$SINGLE' binding operators in a fully qualified name: $name", ) |
|
112
|
|
|
|
|
|
|
if index( $name, SINGLE ) != -1 |
|
113
|
|
|
|
|
|
|
or index( $name, LOOSE ) != -1; |
|
114
|
|
|
|
|
|
|
|
|
115
|
42
|
100
|
|
|
|
352
|
key_failure->throw( |
|
116
|
|
|
|
|
|
|
"cannot have multiple sequential '$TIGHT' binding operators in a fully qualified name: $name", ) |
|
117
|
|
|
|
|
|
|
if $name =~ /[$TIGHT]{2,}/; |
|
118
|
|
|
|
|
|
|
|
|
119
|
41
|
50
|
|
|
|
135
|
key_failure->throw( |
|
120
|
|
|
|
|
|
|
"last component of a fully qualified name must not be a binding operator: $name", ) |
|
121
|
|
|
|
|
|
|
if substr( $name, -1 ) eq TIGHT; |
|
122
|
|
|
|
|
|
|
|
|
123
|
41
|
100
|
|
|
|
117
|
key_failure->throw( |
|
124
|
|
|
|
|
|
|
"first component of a fully qualified name must not be a binding operator: $name", ) |
|
125
|
|
|
|
|
|
|
if substr( $name, 0, 1 ) eq TIGHT; |
|
126
|
|
|
|
|
|
|
|
|
127
|
40
|
|
|
|
|
430
|
return [ split( /[$TIGHT]/, $name ) ]; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
1534
|
|
|
1534
|
1
|
2361
|
sub normalize_key( $key ) { |
|
|
1534
|
|
|
|
|
2532
|
|
|
|
1534
|
|
|
|
|
2375
|
|
|
141
|
1534
|
|
|
|
|
8946
|
$key =~ s/[$TIGHT]?[$LOOSE][$TIGHT]?/$LOOSE/g; |
|
142
|
1534
|
|
|
|
|
3843
|
return $key; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
4
|
|
|
4
|
1
|
8
|
sub name_arr_to_str ( $name_arr ) { |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
9
|
|
|
154
|
4
|
|
|
|
|
22
|
return normalize_key( join( +TIGHT, @$name_arr ) ); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
0
|
1
|
|
sub is_wildcard( $string ) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
167
|
0
|
|
0
|
|
|
|
return $string eq TIGHT || $string eq LOOSE; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# |
|
174
|
|
|
|
|
|
|
# This file is part of Config-XrmDatabase |
|
175
|
|
|
|
|
|
|
# |
|
176
|
|
|
|
|
|
|
# This software is Copyright (c) 2021 by Smithsonian Astrophysical Observatory. |
|
177
|
|
|
|
|
|
|
# |
|
178
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
179
|
|
|
|
|
|
|
# |
|
180
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
|
181
|
|
|
|
|
|
|
# |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__END__ |