Common/SEN.pm

filter: Statementstmt 100% 19 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 25 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Common/CC.pm ↑ Summary Common/URI/RFC1035.pm »
1 package Regexp::Common::SEN;
2  
3 71 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 71 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 71 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 71 ▶no warnings 'syntax';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 71 ▶use Regexp::Common qw /pattern clean no_defaults/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 71 our $VERSION = '2024080801';
12  
13 =begin does_not_exist
14  
15 sub par11 {
16 my $string = shift;
17 my $sum = 0;
18 for my $i (0 .. length ($string) - 1) {
19 my $c = substr ($string, $i, 1);
20 $sum += $c * (length ($string) - $i)
21 }
22 !($sum % 11)
23 }
24  
25 =end does_not_exist
26 =cut
27  
28 # http://www.ssa.gov/history/ssn/geocard.html
29 pattern name => [qw /SEN USA SSN -sep=-/],
30 3225 ▶ create => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 3225 my $sep = $_ [1] {-sep};
32 3225 "(?k:(?k:[1-9][0-9][0-9]|0[1-9][0-9]|00[1-9])$sep" .
33 "(?k:[1-9][0-9]|0[1-9])$sep" .
34 "(?k:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|" .
35 "00[1-9][0-9]|000[1-9]))"
36 },
37 71 ;
38  
39 =begin does_not_exist
40  
41 It's not clear whether this is the right checksum.
42  
43 # http://www.google.nl/search?q=cache:8m1zKNYrEO0J:www.enschede.nl/nieuw/projecten/aanbesteding/integratie/pve%2520Bijlage%25207.5.doc+Sofi+nummer+formaat&hl=en&start=56&lr=lang_en|lang_nl&ie=UTF-8
44 pattern name => [qw /SEN Netherlands SoFi/],
45 create => sub {
46 # 9 digits (d1 d2 d3 d4 d5 d6 d7 d8 d9)
47 # 9*d1 + 8*d2 + 7*d3 + 6*d4 + 5*d5 + 4*d6 + 3*d7 + 2*d8 + 1*d9
48 # == 0 mod 11.
49 qr /([0-9]{9})(?(?{par11 ($^N)})|(?!))/;
50 }
51 ;
52  
53 =end does_not_exist
54 =cut
55  
56 71 1;
57  
58 __END__
« Common/CC.pm ↑ Summary Common/URI/RFC1035.pm »