line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::_support; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
546
|
use 5.10.0; |
|
72
|
|
|
|
|
154
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
235
|
use strict; |
|
72
|
|
|
|
|
141
|
|
|
72
|
|
|
|
|
1145
|
|
6
|
72
|
|
|
72
|
|
213
|
use warnings; |
|
72
|
|
|
|
|
91
|
|
|
72
|
|
|
|
|
2157
|
|
7
|
72
|
|
|
72
|
|
301
|
no warnings 'syntax'; |
|
72
|
|
|
|
|
71
|
|
|
72
|
|
|
|
|
10358
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2017040401'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Returns true/false, depending whether the given the argument |
13
|
|
|
|
|
|
|
# satisfies the LUHN checksum. |
14
|
|
|
|
|
|
|
# See http://www.webopedia.com/TERM/L/Luhn_formula.html. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# Note that this function is intended to be called from regular |
17
|
|
|
|
|
|
|
# expression, so it should NOT use a regular expression in any way. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
sub luhn { |
20
|
204
|
|
|
204
|
1
|
4307
|
my $arg = shift; |
21
|
204
|
|
|
|
|
123
|
my $even = 0; |
22
|
204
|
|
|
|
|
118
|
my $sum = 0; |
23
|
204
|
|
|
|
|
224
|
while (length $arg) { |
24
|
2636
|
|
|
|
|
1669
|
my $num = chop $arg; |
25
|
2636
|
50
|
33
|
|
|
5853
|
return if $num lt '0' || $num gt '9'; |
26
|
2636
|
100
|
100
|
|
|
4531
|
if ($even && (($num *= 2) > 9)) {$num = 1 + ($num % 10)} |
|
644
|
|
|
|
|
407
|
|
27
|
2636
|
|
|
|
|
1393
|
$even = 1 - $even; |
28
|
2636
|
|
|
|
|
2865
|
$sum += $num; |
29
|
|
|
|
|
|
|
} |
30
|
204
|
|
|
|
|
242
|
!($sum % 10) |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
73
|
|
|
73
|
|
107
|
my $pack = shift; |
35
|
73
|
|
|
|
|
110
|
my $caller = caller; |
36
|
72
|
|
|
72
|
|
267
|
no strict 'refs'; |
|
72
|
|
|
|
|
91
|
|
|
72
|
|
|
|
|
4641
|
|
37
|
73
|
|
|
|
|
131
|
*{$caller . "::" . $_} = \&{$pack . "::" . $_} for @_; |
|
73
|
|
|
|
|
7432
|
|
|
73
|
|
|
|
|
214
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |