line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::Common::CC; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
857
|
use 5.10.0; |
|
72
|
|
|
|
|
271
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
393
|
use strict; |
|
72
|
|
|
|
|
861
|
|
|
72
|
|
|
|
|
1566
|
|
6
|
72
|
|
|
72
|
|
349
|
use warnings; |
|
72
|
|
|
|
|
192
|
|
|
72
|
|
|
|
|
2023
|
|
7
|
72
|
|
|
72
|
|
1122
|
no warnings 'syntax'; |
|
72
|
|
|
|
|
157
|
|
|
72
|
|
|
|
|
2516
|
|
8
|
|
|
|
|
|
|
|
9
|
72
|
|
|
72
|
|
435
|
use Regexp::Common qw /pattern clean no_defaults/; |
|
72
|
|
|
|
|
802
|
|
|
72
|
|
|
|
|
474
|
|
10
|
72
|
|
|
72
|
|
21853
|
use Regexp::Common::_support qw /luhn/; |
|
72
|
|
|
|
|
198
|
|
|
72
|
|
|
|
|
436
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '2017060201'; |
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
|
|
430
|
use re 'eval'; |
|
72
|
|
|
|
|
144
|
|
|
72
|
|
|
|
|
7377
|
|
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__ |