File Coverage

blib/lib/Regexp/Common/SEN.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Regexp::Common::SEN;
2              
3 71     71   674 use 5.10.0;
  71         173  
4              
5 71     71   248 use strict;
  71         93  
  71         1240  
6 71     71   209 use warnings;
  71         73  
  71         1537  
7 71     71   202 no warnings 'syntax';
  71         72  
  71         1928  
8              
9 71     71   222 use Regexp::Common qw /pattern clean no_defaults/;
  71         79  
  71         393  
10              
11             our $VERSION = '2016060801';
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             create => sub {
31             my $sep = $_ [1] {-sep};
32             "(?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             ;
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             1;
57              
58             __END__