line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::CC; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
735
|
use 5.10.0; |
|
72
|
|
|
|
|
176
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
262
|
use strict; |
|
72
|
|
|
|
|
84
|
|
|
72
|
|
|
|
|
1274
|
|
6
|
72
|
|
|
72
|
|
225
|
use warnings; |
|
72
|
|
|
|
|
126
|
|
|
72
|
|
|
|
|
1716
|
|
7
|
72
|
|
|
72
|
|
358
|
no warnings 'syntax'; |
|
72
|
|
|
|
|
80
|
|
|
72
|
|
|
|
|
2089
|
|
8
|
|
|
|
|
|
|
|
9
|
72
|
|
|
72
|
|
473
|
use Regexp::Common qw /pattern clean no_defaults/; |
|
72
|
|
|
|
|
83
|
|
|
72
|
|
|
|
|
359
|
|
10
|
72
|
|
|
72
|
|
21545
|
use Regexp::Common::_support qw /luhn/; |
|
72
|
|
|
|
|
114
|
|
|
72
|
|
|
|
|
338
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '2017040401'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @cards = ( |
15
|
|
|
|
|
|
|
# Name Prefix Length mod 10 |
16
|
|
|
|
|
|
|
[Mastercard => '5[1-5]', 16, 1], |
17
|
|
|
|
|
|
|
[Visa => '4', [13, 16], 1], |
18
|
|
|
|
|
|
|
[Amex => '3[47]', 15, 1], |
19
|
|
|
|
|
|
|
# Carte Blanche |
20
|
|
|
|
|
|
|
['Diners Club' => '3(?:0[0-5]|[68])', 14, 1], |
21
|
|
|
|
|
|
|
[Discover => '6011', 16, 1], |
22
|
|
|
|
|
|
|
[enRoute => '2(?:014|149)', 15, 0], |
23
|
|
|
|
|
|
|
[JCB => [['3', 16, 1], |
24
|
|
|
|
|
|
|
['2131|1800', 15, 1]]], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
foreach my $card (@cards) { |
29
|
|
|
|
|
|
|
my ($name, $prefix, $length, $mod) = @$card; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Skip the harder ones for now. |
32
|
|
|
|
|
|
|
next if ref $prefix || ref $length; |
33
|
|
|
|
|
|
|
next unless $mod; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $times = $length + $mod; |
36
|
|
|
|
|
|
|
pattern name => [CC => $name], |
37
|
|
|
|
|
|
|
create => sub { |
38
|
72
|
|
|
72
|
|
427
|
use re 'eval'; |
|
72
|
|
|
|
|
94
|
|
|
72
|
|
|
|
|
6829
|
|
39
|
|
|
|
|
|
|
qr <((?=($prefix))[0-9]{$length}) |
40
|
|
|
|
|
|
|
(?(?{Regexp::Common::_support::luhn $1})|(?!))>x |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |