| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mo::utils::CEFACT; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
176239
|
use base qw(Exporter); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
380
|
|
|
4
|
3
|
|
|
3
|
|
24
|
use strict; |
|
|
3
|
|
|
|
|
10
|
|
|
|
3
|
|
|
|
|
80
|
|
|
5
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
|
3
|
|
|
|
|
15
|
|
|
|
3
|
|
|
|
|
139
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1470
|
use CEFACT::Unit; |
|
|
3
|
|
|
|
|
271686
|
|
|
|
3
|
|
|
|
|
162
|
|
|
8
|
3
|
|
|
3
|
|
24
|
use Error::Pure qw(err); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
175
|
|
|
9
|
3
|
|
|
3
|
|
17
|
use Readonly; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
816
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_cefact_unit); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.03; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub check_cefact_unit { |
|
16
|
4
|
|
|
4
|
1
|
307038
|
my ($self, $key) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
22
|
_check_key($self, $key) && return; |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
100
|
|
|
|
21
|
if (! CEFACT::Unit->new->check_common_code($self->{$key})) { |
|
21
|
|
|
|
|
|
|
err "Parameter '$key' must be a UN/CEFACT unit common code.", |
|
22
|
1
|
|
|
|
|
294750
|
'Value', $self->{$key}, |
|
23
|
|
|
|
|
|
|
; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
277741
|
return; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _check_key { |
|
30
|
4
|
|
|
4
|
|
10
|
my ($self, $key) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
100
|
100
|
|
|
31
|
if (! exists $self->{$key} || ! defined $self->{$key}) { |
|
33
|
2
|
|
|
|
|
7
|
return 1; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
8
|
return 0; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding utf8 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Mo::utils::CEFACT - Mo UN/CEFACT Common Code utilities. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
use Mo::utils::CEFACT qw(check_cefact_unit); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
check_cefact_unit($self, $key); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Mo UN/CEFACT utilities for checking of data objects. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 C<check_cefact_unit> |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
check_cefact_unit($self, $key); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Check parameter defined by C<$key> if it's UN/CEFACT unit Common Code. |
|
68
|
|
|
|
|
|
|
Value could be undefined. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Put error if check isn't ok. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns undef. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 ERRORS |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
check_cefact_unit(): |
|
77
|
|
|
|
|
|
|
Parameter '%s' must be a UN/CEFACT unit common code. |
|
78
|
|
|
|
|
|
|
Value: %s |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=for comment filename=check_cefact_unit_ok.pl |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
use strict; |
|
85
|
|
|
|
|
|
|
use warnings; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
use Mo::utils::CEFACT qw(check_cefact_unit); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $self = { |
|
90
|
|
|
|
|
|
|
'key' => 'DLT', |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
check_cefact_unit($self, 'key'); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Print out. |
|
95
|
|
|
|
|
|
|
print "ok\n"; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Output: |
|
98
|
|
|
|
|
|
|
# ok |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=for comment filename=check_cefact_unit_fail.pl |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use strict; |
|
105
|
|
|
|
|
|
|
use warnings; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use Error::Pure; |
|
108
|
|
|
|
|
|
|
use Mo::utils::CEFACT qw(check_cefact_unit); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $self = { |
|
113
|
|
|
|
|
|
|
'key' => 'xx', |
|
114
|
|
|
|
|
|
|
}; |
|
115
|
|
|
|
|
|
|
check_cefact_unit($self, 'key'); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Print out. |
|
118
|
|
|
|
|
|
|
print "ok\n"; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Output like: |
|
121
|
|
|
|
|
|
|
# #Error [...CEFACT.pm:?] Parameter 'key' must be a UN/CEFACT unit common code. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L<CEFACT::Unit>, |
|
126
|
|
|
|
|
|
|
L<Error::Pure>, |
|
127
|
|
|
|
|
|
|
L<Exporter>, |
|
128
|
|
|
|
|
|
|
L<Readonly>. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item L<Mo> |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Micro Objects. Mo is less. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item L<Mo::utils> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Mo utilities. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Mo-utils-CEFACT> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<http://skim.cz> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
© 2024-2025 Michal Josef Špaček |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
BSD 2-Clause License |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 VERSION |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
0.03 |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |