line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Barcode::Code93; |
2
|
|
|
|
|
|
|
$Barcode::Code93::VERSION = '0.05'; |
3
|
2
|
|
|
2
|
|
53290
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
44
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
4
|
2
|
|
|
2
|
|
817
|
use Moo; |
|
2
|
|
|
|
|
17890
|
|
|
2
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub barcode { |
10
|
1
|
|
|
1
|
1
|
818
|
my ($self, $text) = @_; |
11
|
1
|
|
|
|
|
5
|
my @data = $self->_barcode(uc $text); |
12
|
1
|
50
|
|
|
|
6
|
return wantarray ? @data : \@data; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
17
|
|
|
|
|
|
|
# barcode (from GD::Barcode::Code93) |
18
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
19
|
|
|
|
|
|
|
sub _barcode { |
20
|
1
|
|
|
1
|
|
2
|
my ($self, $text) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
35
|
my %code93bar = ( |
23
|
|
|
|
|
|
|
0 =>'100010100', |
24
|
|
|
|
|
|
|
1 =>'101001000', |
25
|
|
|
|
|
|
|
2 =>'101000100', |
26
|
|
|
|
|
|
|
3 =>'101000010', |
27
|
|
|
|
|
|
|
4 =>'100101000', |
28
|
|
|
|
|
|
|
5 =>'100100100', |
29
|
|
|
|
|
|
|
6 =>'100100010', |
30
|
|
|
|
|
|
|
7 =>'101010000', |
31
|
|
|
|
|
|
|
8 =>'100010010', |
32
|
|
|
|
|
|
|
9 =>'100001010', |
33
|
|
|
|
|
|
|
A =>'110101000', |
34
|
|
|
|
|
|
|
B =>'110100100', |
35
|
|
|
|
|
|
|
C =>'110100010', |
36
|
|
|
|
|
|
|
D =>'110010100', |
37
|
|
|
|
|
|
|
E =>'110010010', |
38
|
|
|
|
|
|
|
F =>'110001010', |
39
|
|
|
|
|
|
|
G =>'101101000', |
40
|
|
|
|
|
|
|
H =>'101100100', |
41
|
|
|
|
|
|
|
I =>'101100010', |
42
|
|
|
|
|
|
|
J =>'100110100', |
43
|
|
|
|
|
|
|
K =>'100011010', |
44
|
|
|
|
|
|
|
L =>'101011000', |
45
|
|
|
|
|
|
|
M =>'101001100', |
46
|
|
|
|
|
|
|
N =>'101000110', |
47
|
|
|
|
|
|
|
O =>'100101100', |
48
|
|
|
|
|
|
|
P =>'100010110', |
49
|
|
|
|
|
|
|
Q =>'110110100', |
50
|
|
|
|
|
|
|
R =>'110110010', |
51
|
|
|
|
|
|
|
S =>'110101100', |
52
|
|
|
|
|
|
|
T =>'110100110', |
53
|
|
|
|
|
|
|
U =>'110010110', |
54
|
|
|
|
|
|
|
V =>'110011010', |
55
|
|
|
|
|
|
|
W =>'101101100', |
56
|
|
|
|
|
|
|
X =>'101100110', |
57
|
|
|
|
|
|
|
Y =>'100110110', |
58
|
|
|
|
|
|
|
Z =>'100111010', |
59
|
|
|
|
|
|
|
' ' =>'111010010', |
60
|
|
|
|
|
|
|
'$' =>'111001010', |
61
|
|
|
|
|
|
|
'%' =>'110101110', |
62
|
|
|
|
|
|
|
'($)'=>'100100110', |
63
|
|
|
|
|
|
|
'(%)'=>'111011010', |
64
|
|
|
|
|
|
|
'(+)'=>'100110010', |
65
|
|
|
|
|
|
|
'(/)'=>'111010110', |
66
|
|
|
|
|
|
|
'+' =>'101110110', |
67
|
|
|
|
|
|
|
'-' =>'100101110', |
68
|
|
|
|
|
|
|
'.' =>'111010100', |
69
|
|
|
|
|
|
|
'/' =>'101101110', |
70
|
|
|
|
|
|
|
'*' =>'101011110', ##Start/Stop |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
3
|
my @sum_text = ('*', $self->calculateSums($text), '*'); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
2
|
my @rv = map { split //, $code93bar{$_} } @sum_text; |
|
10
|
|
|
|
|
30
|
|
76
|
1
|
|
|
|
|
3
|
push @rv, 1; |
77
|
1
|
|
|
|
|
31
|
return @rv; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
82
|
|
|
|
|
|
|
# calculateSums (from GD::Barcode::Code93) |
83
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
84
|
|
|
|
|
|
|
sub calculateSums { |
85
|
1
|
|
|
1
|
1
|
2
|
my ($self, $text) = @_; |
86
|
1
|
50
|
|
|
|
4
|
$text = '' unless defined $text; |
87
|
1
|
|
|
|
|
5
|
my @array = split(//, scalar reverse $text); |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
10
|
my %code93values = ( |
90
|
|
|
|
|
|
|
'0' =>'0', |
91
|
|
|
|
|
|
|
'1' =>'1', |
92
|
|
|
|
|
|
|
'2' =>'2', |
93
|
|
|
|
|
|
|
'3' =>'3', |
94
|
|
|
|
|
|
|
'4' =>'4', |
95
|
|
|
|
|
|
|
'5' =>'5', |
96
|
|
|
|
|
|
|
'6' =>'6', |
97
|
|
|
|
|
|
|
'7' =>'7', |
98
|
|
|
|
|
|
|
'8' =>'8', |
99
|
|
|
|
|
|
|
'9' =>'9', |
100
|
|
|
|
|
|
|
'A' =>'10', |
101
|
|
|
|
|
|
|
'B' =>'11', |
102
|
|
|
|
|
|
|
'C' =>'12', |
103
|
|
|
|
|
|
|
'D' =>'13', |
104
|
|
|
|
|
|
|
'E' =>'14', |
105
|
|
|
|
|
|
|
'F' =>'15', |
106
|
|
|
|
|
|
|
'G' =>'16', |
107
|
|
|
|
|
|
|
'H' =>'17', |
108
|
|
|
|
|
|
|
'I' =>'18', |
109
|
|
|
|
|
|
|
'J' =>'19', |
110
|
|
|
|
|
|
|
'K' =>'20', |
111
|
|
|
|
|
|
|
'L' =>'21', |
112
|
|
|
|
|
|
|
'M' =>'22', |
113
|
|
|
|
|
|
|
'N' =>'23', |
114
|
|
|
|
|
|
|
'O' =>'24', |
115
|
|
|
|
|
|
|
'P' =>'25', |
116
|
|
|
|
|
|
|
'Q' =>'26', |
117
|
|
|
|
|
|
|
'R' =>'27', |
118
|
|
|
|
|
|
|
'S' =>'28', |
119
|
|
|
|
|
|
|
'T' =>'29', |
120
|
|
|
|
|
|
|
'U' =>'30', |
121
|
|
|
|
|
|
|
'V' =>'31', |
122
|
|
|
|
|
|
|
'W' =>'32', |
123
|
|
|
|
|
|
|
'X' =>'33', |
124
|
|
|
|
|
|
|
'Y' =>'34', |
125
|
|
|
|
|
|
|
'Z' =>'35', |
126
|
|
|
|
|
|
|
'-' =>'36', |
127
|
|
|
|
|
|
|
'.' =>'37', |
128
|
|
|
|
|
|
|
' ' =>'38', |
129
|
|
|
|
|
|
|
'$' =>'39', |
130
|
|
|
|
|
|
|
'/' =>'40', |
131
|
|
|
|
|
|
|
'+' =>'41', |
132
|
|
|
|
|
|
|
'%' =>'42', |
133
|
|
|
|
|
|
|
'($)' =>'43', |
134
|
|
|
|
|
|
|
'(%)' =>'44', |
135
|
|
|
|
|
|
|
'(/)' =>'45', |
136
|
|
|
|
|
|
|
'(+)' =>'46', |
137
|
|
|
|
|
|
|
'*' => '', |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
29
|
my %invCode93Values = reverse %code93values; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
4
|
foreach my $counter (20, 15) { |
143
|
2
|
|
|
|
|
2
|
my $weighted_sum = 0; |
144
|
2
|
|
|
|
|
2
|
my $x = 1; |
145
|
2
|
|
|
|
|
3
|
foreach my $letter (@array) { |
146
|
13
|
50
|
|
|
|
18
|
if ($x > $counter) { $x = 1 } |
|
0
|
|
|
|
|
0
|
|
147
|
13
|
|
|
|
|
16
|
$weighted_sum += ($code93values{$letter} * $x); |
148
|
13
|
|
|
|
|
14
|
$x++; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
2
|
|
|
|
|
5
|
my $check = $invCode93Values{($weighted_sum % 47)}; |
152
|
2
|
|
|
|
|
5
|
unshift @array, $check; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
11
|
return reverse @array; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__END__ |