line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::_support; |
2
|
|
|
|
|
|
|
|
3
|
71
|
|
|
71
|
|
517
|
use 5.10.0; |
|
71
|
|
|
|
|
160
|
|
4
|
|
|
|
|
|
|
|
5
|
71
|
|
|
71
|
|
233
|
use strict; |
|
71
|
|
|
|
|
67
|
|
|
71
|
|
|
|
|
1043
|
|
6
|
71
|
|
|
71
|
|
227
|
use warnings; |
|
71
|
|
|
|
|
70
|
|
|
71
|
|
|
|
|
1388
|
|
7
|
71
|
|
|
71
|
|
242
|
no warnings 'syntax'; |
|
71
|
|
|
|
|
666
|
|
|
71
|
|
|
|
|
8769
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2016060801'; |
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
|
4748
|
my $arg = shift; |
21
|
204
|
|
|
|
|
122
|
my $even = 0; |
22
|
204
|
|
|
|
|
123
|
my $sum = 0; |
23
|
204
|
|
|
|
|
227
|
while (length $arg) { |
24
|
3268
|
|
|
|
|
1918
|
my $num = chop $arg; |
25
|
3268
|
50
|
33
|
|
|
7168
|
return if $num lt '0' || $num gt '9'; |
26
|
3268
|
100
|
100
|
|
|
5601
|
if ($even && (($num *= 2) > 9)) {$num = 1 + ($num % 10)} |
|
780
|
|
|
|
|
530
|
|
27
|
3268
|
|
|
|
|
1789
|
$even = 1 - $even; |
28
|
3268
|
|
|
|
|
3413
|
$sum += $num; |
29
|
|
|
|
|
|
|
} |
30
|
204
|
|
|
|
|
244
|
!($sum % 10) |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
72
|
|
|
72
|
|
252
|
my $pack = shift; |
35
|
72
|
|
|
|
|
113
|
my $caller = caller; |
36
|
71
|
|
|
71
|
|
303
|
no strict 'refs'; |
|
71
|
|
|
|
|
76
|
|
|
71
|
|
|
|
|
4417
|
|
37
|
72
|
|
|
|
|
147
|
*{$caller . "::" . $_} = \&{$pack . "::" . $_} for @_; |
|
72
|
|
|
|
|
7126
|
|
|
72
|
|
|
|
|
216
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |