line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::CC; |
2
|
|
|
|
|
|
|
|
3
|
71
|
|
|
71
|
|
616
|
use 5.10.0; |
|
71
|
|
|
|
|
813
|
|
4
|
|
|
|
|
|
|
|
5
|
71
|
|
|
71
|
|
265
|
use strict; |
|
71
|
|
|
|
|
87
|
|
|
71
|
|
|
|
|
1768
|
|
6
|
71
|
|
|
71
|
|
236
|
use warnings; |
|
71
|
|
|
|
|
76
|
|
|
71
|
|
|
|
|
1539
|
|
7
|
71
|
|
|
71
|
|
208
|
no warnings 'syntax'; |
|
71
|
|
|
|
|
81
|
|
|
71
|
|
|
|
|
2055
|
|
8
|
|
|
|
|
|
|
|
9
|
71
|
|
|
71
|
|
251
|
use Regexp::Common qw /pattern clean no_defaults/; |
|
71
|
|
|
|
|
86
|
|
|
71
|
|
|
|
|
373
|
|
10
|
71
|
|
|
71
|
|
20196
|
use Regexp::Common::_support qw /luhn/; |
|
71
|
|
|
|
|
102
|
|
|
71
|
|
|
|
|
329
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '2016060801'; |
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
|
71
|
|
|
71
|
|
274
|
use re 'eval'; |
|
71
|
|
|
|
|
76
|
|
|
71
|
|
|
|
|
6208
|
|
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__ |