line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::_support; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
761
|
use 5.10.0; |
|
72
|
|
|
|
|
250
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
379
|
use strict; |
|
72
|
|
|
|
|
160
|
|
|
72
|
|
|
|
|
1282
|
|
6
|
72
|
|
|
72
|
|
348
|
use warnings; |
|
72
|
|
|
|
|
152
|
|
|
72
|
|
|
|
|
1684
|
|
7
|
72
|
|
|
72
|
|
1086
|
no warnings 'syntax'; |
|
72
|
|
|
|
|
158
|
|
|
72
|
|
|
|
|
10871
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2017060201'; |
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
|
8714
|
my $arg = shift; |
21
|
204
|
|
|
|
|
266
|
my $even = 0; |
22
|
204
|
|
|
|
|
272
|
my $sum = 0; |
23
|
204
|
|
|
|
|
379
|
while (length $arg) { |
24
|
2940
|
|
|
|
|
3933
|
my $num = chop $arg; |
25
|
2940
|
50
|
33
|
|
|
9442
|
return if $num lt '0' || $num gt '9'; |
26
|
2940
|
100
|
100
|
|
|
7717
|
if ($even && (($num *= 2) > 9)) {$num = 1 + ($num % 10)} |
|
734
|
|
|
|
|
979
|
|
27
|
2940
|
|
|
|
|
3514
|
$even = 1 - $even; |
28
|
2940
|
|
|
|
|
5453
|
$sum += $num; |
29
|
|
|
|
|
|
|
} |
30
|
204
|
|
|
|
|
443
|
!($sum % 10) |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
73
|
|
|
73
|
|
214
|
my $pack = shift; |
35
|
73
|
|
|
|
|
199
|
my $caller = caller; |
36
|
72
|
|
|
72
|
|
453
|
no strict 'refs'; |
|
72
|
|
|
|
|
178
|
|
|
72
|
|
|
|
|
5288
|
|
37
|
73
|
|
|
|
|
227
|
*{$caller . "::" . $_} = \&{$pack . "::" . $_} for @_; |
|
73
|
|
|
|
|
7862
|
|
|
73
|
|
|
|
|
295
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |