1Algorithm::CheckDigits:U:sMe1r1_C0o0n9t(r3ipbmu)ted PerlAlDgoocruimtehnmt:a:tCihoenckDigits::M11_009(3pm)
2
3
4
6 CheckDigits::M11_009 - compute check digits NRIC (SG)
7
9 use Algorithm::CheckDigits;
10
11 $nric = CheckDigits('nric_sg');
12
13 if ($nric->is_valid('S1234567D')) {
14 # do something
15 }
16
17 $cn = $nric->complete('S1234567');
18 # $cn = 'S1234567D'
19
20 $cd = $nric->checkdigit('S1234567D');
21 # $cd = 'D'
22
23 $bn = $nric->basenumber('S1234567D');
24 # $bn = 'S1234567';
25
27 ALGORITHM
28 1. Beginning left every digit is weighted with 2, 7, 6, 5, 4, 3, 2
29
30 2. The weighted digits are added.
31
32 3. The sum from step 2 is taken modulo 11.
33
34 4. The checkdigit is 11 minus the sum from step 3 converted to a
35 character according to the following table:
36
37 @cd = ('','A','B','C','D','E','F','G','H','I','Z','J', );
38
39 METHODS
40 is_valid($number)
41 Returns true only if $number consists of seven digits (optional
42 preceded by a letter out of 'F', 'G', 'S', 'T') followed by a valid
43 letter according to the algorithm given above.
44
45 Returns false otherwise,
46
47 complete($number)
48 The check letter for $number is computed and appended to the end of
49 $number.
50
51 Returns the complete number with check digit or '' if $number does
52 not consist solely of digits and letters.
53
54 basenumber($number)
55 Returns the basenumber of $number if $number has a valid check
56 digit.
57
58 Return '' otherwise.
59
60 checkdigit($number)
61 Returns '' if $number is valid.
62
63 Return undef otherwise.
64
65 EXPORT
66 None by default.
67
69 Mathias Weidner, "<mamawe@cpan.org>"
70
72 perl, CheckDigits, www.pruefziffernberechnung.de,
73
74
75
76perl v5.38.0 2023-07-2A0lgorithm::CheckDigits::M11_009(3pm)