Filename | /usr/share/perl5/Algorithm/CheckDigits.pm |
Statements | Executed 23 statements in 996µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 39µs | 39µs | BEGIN@4 | Algorithm::CheckDigits::
1 | 1 | 1 | 17µs | 59µs | BEGIN@8 | Algorithm::CheckDigits::
1 | 1 | 1 | 16µs | 76µs | BEGIN@7 | Algorithm::CheckDigits::
1 | 1 | 1 | 11µs | 24µs | BEGIN@6 | Algorithm::CheckDigits::
1 | 1 | 1 | 10µs | 15µs | BEGIN@5 | Algorithm::CheckDigits::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | Algorithm::CheckDigits::
0 | 0 | 0 | 0s | 0s | CheckDigits | Algorithm::CheckDigits::
0 | 0 | 0 | 0s | 0s | DESTROY | Algorithm::CheckDigits::
0 | 0 | 0 | 0s | 0s | method_list | Algorithm::CheckDigits::
0 | 0 | 0 | 0s | 0s | print_methods | Algorithm::CheckDigits::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # vim: ts=4 sw=4 tw=78 et si: | ||||
2 | package Algorithm::CheckDigits; | ||||
3 | |||||
4 | 3 | 53µs | 1 | 39µs | # spent 39µs within Algorithm::CheckDigits::BEGIN@4 which was called:
# once (39µs+0s) by C4::Circulation::BEGIN@45 at line 4 # spent 39µs making 1 call to Algorithm::CheckDigits::BEGIN@4 |
5 | 3 | 24µs | 2 | 19µs | # spent 15µs (10+4) within Algorithm::CheckDigits::BEGIN@5 which was called:
# once (10µs+4µs) by C4::Circulation::BEGIN@45 at line 5 # spent 15µs making 1 call to Algorithm::CheckDigits::BEGIN@5
# spent 4µs making 1 call to strict::import |
6 | 3 | 26µs | 2 | 36µs | # spent 24µs (11+13) within Algorithm::CheckDigits::BEGIN@6 which was called:
# once (11µs+13µs) by C4::Circulation::BEGIN@45 at line 6 # spent 24µs making 1 call to Algorithm::CheckDigits::BEGIN@6
# spent 13µs making 1 call to warnings::import |
7 | 3 | 70µs | 2 | 136µs | # spent 76µs (16+60) within Algorithm::CheckDigits::BEGIN@7 which was called:
# once (16µs+60µs) by C4::Circulation::BEGIN@45 at line 7 # spent 76µs making 1 call to Algorithm::CheckDigits::BEGIN@7
# spent 60µs making 1 call to Exporter::import |
8 | 3 | 686µs | 2 | 102µs | # spent 59µs (17+43) within Algorithm::CheckDigits::BEGIN@8 which was called:
# once (17µs+43µs) by C4::Circulation::BEGIN@45 at line 8 # spent 59µs making 1 call to Algorithm::CheckDigits::BEGIN@8
# spent 43µs making 1 call to vars::import |
9 | |||||
10 | 1 | 1µs | require Exporter; | ||
11 | |||||
12 | 1 | 12µs | our @ISA = qw(Exporter); | ||
13 | |||||
14 | # Items to export into callers namespace by default. Note: do not export | ||||
15 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||
16 | # Do not simply export all your public functions/methods/constants. | ||||
17 | |||||
18 | # This allows declaration use CheckDigits ':all'; | ||||
19 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||
20 | # will save memory. | ||||
21 | 1 | 3µs | our %EXPORT_TAGS = ( | ||
22 | 'all' => [ | ||||
23 | qw( | ||||
24 | CheckDigits method_list print_methods | ||||
25 | ) ] ); | ||||
26 | |||||
27 | 1 | 2µs | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
28 | |||||
29 | 1 | 500ns | our @EXPORT = qw( CheckDigits ); | ||
30 | |||||
31 | 1 | 400ns | our $VERSION = '0.50'; | ||
32 | |||||
33 | 1 | 91µs | my %methods = ( | ||
34 | 'mbase-001' => 'Algorithm::CheckDigits::MBase_001', | ||||
35 | 'upc' => 'Algorithm::CheckDigits::MBase_001', | ||||
36 | 'mbase-002' => 'Algorithm::CheckDigits::MBase_002', | ||||
37 | 'blutbeutel' => 'Algorithm::CheckDigits::MBase_002', | ||||
38 | 'bzue_de' => 'Algorithm::CheckDigits::MBase_002', | ||||
39 | 'ustid_de' => 'Algorithm::CheckDigits::MBase_002', | ||||
40 | 'vatrn_de' => 'Algorithm::CheckDigits::MBase_002', | ||||
41 | 'mbase-003' => 'Algorithm::CheckDigits::MBase_003', | ||||
42 | 'sici' => 'Algorithm::CheckDigits::MBase_003', | ||||
43 | 'm07-001' => 'Algorithm::CheckDigits::M07_001', | ||||
44 | 'm09-001' => 'Algorithm::CheckDigits::M09_001', | ||||
45 | 'euronote' => 'Algorithm::CheckDigits::M09_001', | ||||
46 | 'm10-001' => 'Algorithm::CheckDigits::M10_001', | ||||
47 | 'amex' => 'Algorithm::CheckDigits::M10_001', | ||||
48 | 'bahncard' => 'Algorithm::CheckDigits::M10_001', | ||||
49 | 'diners' => 'Algorithm::CheckDigits::M10_001', | ||||
50 | 'discover' => 'Algorithm::CheckDigits::M10_001', | ||||
51 | 'enroute' => 'Algorithm::CheckDigits::M10_001', | ||||
52 | 'eurocard' => 'Algorithm::CheckDigits::M10_001', | ||||
53 | 'happydigits' => 'Algorithm::CheckDigits::M10_001', | ||||
54 | 'jcb' => 'Algorithm::CheckDigits::M10_001', | ||||
55 | 'klubkarstadt' => 'Algorithm::CheckDigits::M10_001', | ||||
56 | 'mastercard' => 'Algorithm::CheckDigits::M10_001', | ||||
57 | 'miles&more' => 'Algorithm::CheckDigits::M10_001', | ||||
58 | 'visa' => 'Algorithm::CheckDigits::M10_001', | ||||
59 | 'isin' => 'Algorithm::CheckDigits::M10_001', | ||||
60 | 'imei' => 'Algorithm::CheckDigits::M10_001', | ||||
61 | 'imeisv' => 'Algorithm::CheckDigits::M10_001', | ||||
62 | 'm10-002' => 'Algorithm::CheckDigits::M10_002', | ||||
63 | 'siren' => 'Algorithm::CheckDigits::M10_002', | ||||
64 | 'siret' => 'Algorithm::CheckDigits::M10_002', | ||||
65 | 'm10-003' => 'Algorithm::CheckDigits::M10_003', | ||||
66 | 'ismn' => 'Algorithm::CheckDigits::M10_003', | ||||
67 | 'm10-004' => 'Algorithm::CheckDigits::M10_004', | ||||
68 | 'ean' => 'Algorithm::CheckDigits::M10_004', | ||||
69 | 'iln' => 'Algorithm::CheckDigits::M10_004', | ||||
70 | 'nve' => 'Algorithm::CheckDigits::M10_004', | ||||
71 | '2aus5' => 'Algorithm::CheckDigits::M10_004', | ||||
72 | 'isbn13' => 'Algorithm::CheckDigits::M10_004', | ||||
73 | 'm10-005' => 'Algorithm::CheckDigits::M10_005', | ||||
74 | 'identcode_dp' => 'Algorithm::CheckDigits::M10_005', | ||||
75 | 'leitcode_dp' => 'Algorithm::CheckDigits::M10_005', | ||||
76 | 'm10-006' => 'Algorithm::CheckDigits::M10_006', | ||||
77 | 'rentenversicherung' => 'Algorithm::CheckDigits::M10_006', | ||||
78 | 'm10-008' => 'Algorithm::CheckDigits::M10_008', | ||||
79 | 'sedol' => 'Algorithm::CheckDigits::M10_008', | ||||
80 | 'm10-009' => 'Algorithm::CheckDigits::M10_009', | ||||
81 | 'betriebsnummer' => 'Algorithm::CheckDigits::M10_009', | ||||
82 | 'm10-010' => 'Algorithm::CheckDigits::M10_010', | ||||
83 | 'postcheckkonti' => 'Algorithm::CheckDigits::M10_010', | ||||
84 | 'm10-011' => 'Algorithm::CheckDigits::M10_011', | ||||
85 | 'ups' => 'Algorithm::CheckDigits::M10_011', | ||||
86 | 'm11-001' => 'Algorithm::CheckDigits::M11_001', | ||||
87 | 'isbn' => 'Algorithm::CheckDigits::M11_001', | ||||
88 | 'issn' => 'Algorithm::CheckDigits::M11_001', | ||||
89 | 'ustid_pt' => 'Algorithm::CheckDigits::M11_001', | ||||
90 | 'vatrn_pt' => 'Algorithm::CheckDigits::M11_001', | ||||
91 | 'hkid' => 'Algorithm::CheckDigits::M11_001', | ||||
92 | 'wagonnr_br' => 'Algorithm::CheckDigits::M11_001', | ||||
93 | 'nhs_gb' => 'Algorithm::CheckDigits::M11_001', | ||||
94 | 'vat_sl' => 'Algorithm::CheckDigits::M11_001', | ||||
95 | 'm11-002' => 'Algorithm::CheckDigits::M11_002', | ||||
96 | 'pzn' => 'Algorithm::CheckDigits::M11_002', | ||||
97 | 'm11-003' => 'Algorithm::CheckDigits::M11_003', | ||||
98 | 'pkz' => 'Algorithm::CheckDigits::M11_003', | ||||
99 | 'm11-004' => 'Algorithm::CheckDigits::M11_004', | ||||
100 | 'cpf' => 'Algorithm::CheckDigits::M11_004', | ||||
101 | 'titulo_eleitor' => 'Algorithm::CheckDigits::M11_004', | ||||
102 | 'm11-006' => 'Algorithm::CheckDigits::M11_006', | ||||
103 | 'ccc_es' => 'Algorithm::CheckDigits::M11_006', | ||||
104 | 'm11-007' => 'Algorithm::CheckDigits::M11_007', | ||||
105 | 'ustid_fi' => 'Algorithm::CheckDigits::M11_007', | ||||
106 | 'vatrn_fi' => 'Algorithm::CheckDigits::M11_007', | ||||
107 | 'm11-008' => 'Algorithm::CheckDigits::M11_008', | ||||
108 | 'ustid_dk' => 'Algorithm::CheckDigits::M11_008', | ||||
109 | 'vatrn_dk' => 'Algorithm::CheckDigits::M11_008', | ||||
110 | 'm11-009' => 'Algorithm::CheckDigits::M11_009', | ||||
111 | 'nric_sg' => 'Algorithm::CheckDigits::M11_009', | ||||
112 | 'm11-010' => 'Algorithm::CheckDigits::M11_010', | ||||
113 | 'ahv_ch' => 'Algorithm::CheckDigits::M11_010', | ||||
114 | 'm11-011' => 'Algorithm::CheckDigits::M11_011', | ||||
115 | 'ustid_nl' => 'Algorithm::CheckDigits::M11_011', | ||||
116 | 'vatrn_nl' => 'Algorithm::CheckDigits::M11_011', | ||||
117 | 'm11-012' => 'Algorithm::CheckDigits::M11_012', | ||||
118 | 'bwpk_de' => 'Algorithm::CheckDigits::M11_012', | ||||
119 | 'm11-013' => 'Algorithm::CheckDigits::M11_013', | ||||
120 | 'ustid_gr' => 'Algorithm::CheckDigits::M11_013', | ||||
121 | 'vatrn_gr' => 'Algorithm::CheckDigits::M11_013', | ||||
122 | 'm11-015' => 'Algorithm::CheckDigits::M11_015', | ||||
123 | 'esr5_ch' => 'Algorithm::CheckDigits::M11_015', | ||||
124 | 'm11-016' => 'Algorithm::CheckDigits::M11_016', | ||||
125 | 'ustid_pl' => 'Algorithm::CheckDigits::M11_016', | ||||
126 | 'vatrn_pl' => 'Algorithm::CheckDigits::M11_016', | ||||
127 | 'm11-017' => 'Algorithm::CheckDigits::M11_017', | ||||
128 | 'ecno' => 'Algorithm::CheckDigits::M11_017', | ||||
129 | 'ec-no' => 'Algorithm::CheckDigits::M11_017', | ||||
130 | 'einecs' => 'Algorithm::CheckDigits::M11_017', | ||||
131 | 'elincs' => 'Algorithm::CheckDigits::M11_017', | ||||
132 | 'm16-001' => 'Algorithm::CheckDigits::M16_001', | ||||
133 | 'isan' => 'Algorithm::CheckDigits::M16_001', | ||||
134 | 'm23-001' => 'Algorithm::CheckDigits::M23_001', | ||||
135 | 'dni_es' => 'Algorithm::CheckDigits::M23_001', | ||||
136 | 'm23-002' => 'Algorithm::CheckDigits::M23_002', | ||||
137 | 'ustid_ie' => 'Algorithm::CheckDigits::M23_002', | ||||
138 | 'vatrn_ie' => 'Algorithm::CheckDigits::M23_002', | ||||
139 | 'm43-001' => 'Algorithm::CheckDigits::M43_001', | ||||
140 | 'code_39' => 'Algorithm::CheckDigits::M43_001', | ||||
141 | 'm89-001' => 'Algorithm::CheckDigits::M89_001', | ||||
142 | 'ustid_lu' => 'Algorithm::CheckDigits::M89_001', | ||||
143 | 'vatrn_lu' => 'Algorithm::CheckDigits::M89_001', | ||||
144 | 'm97-001' => 'Algorithm::CheckDigits::M97_001', | ||||
145 | 'ustid_be' => 'Algorithm::CheckDigits::M97_001', | ||||
146 | 'vatrn_be' => 'Algorithm::CheckDigits::M97_001', | ||||
147 | 'm97-002' => 'Algorithm::CheckDigits::M97_002', | ||||
148 | 'iban' => 'Algorithm::CheckDigits::M97_002', | ||||
149 | 'mxx-001' => 'Algorithm::CheckDigits::MXX_001', | ||||
150 | 'pa_de' => 'Algorithm::CheckDigits::MXX_001', | ||||
151 | 'mxx-002' => 'Algorithm::CheckDigits::MXX_002', | ||||
152 | 'cas' => 'Algorithm::CheckDigits::MXX_002', | ||||
153 | 'mxx-003' => 'Algorithm::CheckDigits::MXX_003', | ||||
154 | 'dem' => 'Algorithm::CheckDigits::MXX_003', | ||||
155 | 'mxx-004' => 'Algorithm::CheckDigits::MXX_004', | ||||
156 | 'ustid_at' => 'Algorithm::CheckDigits::MXX_004', | ||||
157 | 'vatrn_at' => 'Algorithm::CheckDigits::MXX_004', | ||||
158 | 'mxx-005' => 'Algorithm::CheckDigits::MXX_005', | ||||
159 | 'esr9_ch' => 'Algorithm::CheckDigits::MXX_005', | ||||
160 | 'verhoeff' => 'Algorithm::CheckDigits::MXX_006', | ||||
161 | ); | ||||
162 | |||||
163 | sub CheckDigits { | ||||
164 | my $method = shift || ''; | ||||
165 | |||||
166 | if ( my $pkg = $methods{ lc($method) } ) { | ||||
167 | my $file = $pkg; | ||||
168 | $file =~ s{::}{/}g; | ||||
169 | require "$file.pm"; | ||||
170 | return new $pkg($method); | ||||
171 | } | ||||
172 | else { | ||||
173 | die "Don't know checkdigit algorithm for '$method'!"; | ||||
174 | } | ||||
175 | } # CheckDigits() | ||||
176 | |||||
177 | sub method_list { | ||||
178 | my @methods = (); | ||||
179 | foreach my $method ( sort keys %methods ) { | ||||
180 | push @methods, $method; | ||||
181 | } | ||||
182 | return wantarray ? @methods : \@methods; | ||||
183 | } # method_list() | ||||
184 | |||||
185 | sub print_methods { | ||||
186 | foreach my $method ( sort keys %methods ) { | ||||
187 | print "$method => $methods{$method}\n"; | ||||
188 | } | ||||
189 | } # print_methods() | ||||
190 | |||||
191 | sub AUTOLOAD { | ||||
192 | my $self = shift; | ||||
193 | my $attr = $AUTOLOAD; | ||||
194 | unless ( $attr =~ /^Algorithm::CheckDigits::[A-Za-z_0-9]*$/ ) { | ||||
195 | croak "$attr is not defined"; | ||||
196 | } | ||||
197 | return ''; | ||||
198 | } # AUTOLOAD() | ||||
199 | |||||
200 | sub DESTROY { | ||||
201 | } | ||||
202 | |||||
203 | # Preloaded methods go here. | ||||
204 | |||||
205 | 1 | 28µs | 1; | ||
206 | __END__ |