line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Parity; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
655
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
901
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "1.32"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
setEvenParity setOddParity |
15
|
|
|
|
|
|
|
setMarkParity setSpaceParity |
16
|
|
|
|
|
|
|
EvenBytes OddBytes |
17
|
|
|
|
|
|
|
MarkBytes SpaceBytes |
18
|
|
|
|
|
|
|
isEvenParity isOddParity |
19
|
|
|
|
|
|
|
isMarkParity isSpaceParity |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
23
|
|
|
|
|
|
|
showParity showMarkSpace |
24
|
|
|
|
|
|
|
$even_parity $odd_parity |
25
|
|
|
|
|
|
|
$show_parity $even_codes |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
our ($even_parity, $odd_parity, $show_parity); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $even_bits = "\0"; |
30
|
|
|
|
|
|
|
my $odd_bits = "\200"; |
31
|
|
|
|
|
|
|
foreach (0 .. 7) { |
32
|
|
|
|
|
|
|
$even_bits .= $odd_bits; |
33
|
|
|
|
|
|
|
($odd_bits = $even_bits) =~ tr/\0\200/\200\0/; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $codes = pack('C*', (0 .. 255)); |
37
|
|
|
|
|
|
|
($even_parity = $codes ^ $even_bits) =~ s/(\W)/sprintf('\%o', ord $1)/eg; |
38
|
|
|
|
|
|
|
($odd_parity = $codes ^ $odd_bits) =~ s/(\W)/sprintf('\%o', ord $1)/eg; |
39
|
|
|
|
|
|
|
($show_parity = $even_bits) =~ tr /\0\200/eo/; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $even_codes = ''; |
42
|
|
|
|
|
|
|
while ($even_bits =~ /\0/g) { |
43
|
|
|
|
|
|
|
$even_codes .= sprintf '\%o', (pos $even_bits) - 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
4
|
100
|
|
4
|
1
|
68
|
eval <
|
|
4
|
100
|
|
4
|
1
|
8
|
|
|
4
|
50
|
|
2
|
1
|
10
|
|
|
4
|
|
|
2
|
1
|
12
|
|
|
4
|
|
|
2
|
1
|
6
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
108
|
|
|
2
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
100
|
|
|
2
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
67
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
12
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub setEvenParity { |
49
|
|
|
|
|
|
|
my(\@s) = \@_; |
50
|
|
|
|
|
|
|
foreach (\@s) { |
51
|
|
|
|
|
|
|
tr/\\0-\\377/$even_parity/; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
wantarray ? \@s : join '', \@s; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub setOddParity { |
57
|
|
|
|
|
|
|
my(\@s) = \@_; |
58
|
|
|
|
|
|
|
foreach (\@s) { |
59
|
|
|
|
|
|
|
tr/\\0-\\377/$odd_parity/; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
wantarray ? \@s : join '', \@s; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub showParity { |
65
|
|
|
|
|
|
|
my(\@s) = \@_; |
66
|
|
|
|
|
|
|
foreach (\@s) { |
67
|
|
|
|
|
|
|
tr/\\0-\\377/$show_parity/; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
wantarray ? \@s : join '', \@s; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub EvenBytes { |
73
|
|
|
|
|
|
|
my \$count = 0; |
74
|
|
|
|
|
|
|
foreach (\@_) { |
75
|
|
|
|
|
|
|
\$count += tr/$even_codes//; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
\$count; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub OddBytes { |
81
|
|
|
|
|
|
|
my \$count = 0; |
82
|
|
|
|
|
|
|
foreach (\@_) { |
83
|
|
|
|
|
|
|
\$count += tr/$even_codes//c; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
\$count; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
EDQ |
89
|
|
|
|
|
|
|
die $@ if $@; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub isEvenParity { |
92
|
2
|
|
|
2
|
1
|
70
|
! &OddBytes; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub isOddParity { |
96
|
2
|
|
|
2
|
1
|
66
|
! &EvenBytes; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub setSpaceParity { |
100
|
2
|
|
|
2
|
1
|
38
|
my(@s) = @_; |
101
|
2
|
|
|
|
|
21
|
foreach (@s) { |
102
|
4
|
|
|
|
|
9
|
tr/\200-\377/\0-\177/; |
103
|
|
|
|
|
|
|
} |
104
|
2
|
100
|
|
|
|
28
|
wantarray ? @s : join '', @s; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub setMarkParity { |
108
|
2
|
|
|
2
|
1
|
19
|
my(@s) = @_; |
109
|
2
|
|
|
|
|
6
|
foreach (@s) { |
110
|
4
|
|
|
|
|
8
|
tr/\0-\177/\200-\377/; |
111
|
|
|
|
|
|
|
} |
112
|
2
|
100
|
|
|
|
11
|
wantarray ? @s : join '', @s; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub showMarkSpace { |
116
|
2
|
|
|
2
|
1
|
19
|
my(@s) = @_; |
117
|
2
|
|
|
|
|
5
|
foreach (@s) { |
118
|
2
|
|
|
|
|
3
|
tr/\0-\177/s/; |
119
|
2
|
|
|
|
|
5
|
tr/\200-\377/m/; |
120
|
|
|
|
|
|
|
} |
121
|
2
|
50
|
|
|
|
21
|
wantarray ? @s : join '', @s; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub SpaceBytes { |
125
|
6
|
|
|
6
|
1
|
7
|
my $count = 0; |
126
|
6
|
|
|
|
|
11
|
foreach (@_) { |
127
|
6
|
|
|
|
|
12
|
$count += tr/\0-\177//; |
128
|
|
|
|
|
|
|
} |
129
|
6
|
|
|
|
|
18
|
$count; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub MarkBytes { |
133
|
6
|
|
|
6
|
1
|
9
|
my $count = 0; |
134
|
6
|
|
|
|
|
10
|
foreach (@_) { |
135
|
6
|
|
|
|
|
12
|
$count += tr/\200-\377//; |
136
|
|
|
|
|
|
|
} |
137
|
6
|
|
|
|
|
19
|
$count; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub isSpaceParity { |
141
|
4
|
|
|
4
|
1
|
36
|
! &MarkBytes; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub isMarkParity { |
145
|
4
|
|
|
4
|
1
|
38
|
! &SpaceBytes; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |