1Algorithm::CheckDigits:U:sMe1r1_C0o0n4t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M11_004(3)
2
3
4

NAME

6       CheckDigits::M11_004 - compute check digits for CPF (BR), Titulo
7       Eleitoral (BR)
8

SYNOPSIS

10         use Algorithm::CheckDigits;
11
12         $cpf = CheckDigits('cpf');
13
14         if ($cpf->is_valid('043.033.407-90')) {
15               # do something
16         }
17
18         $cn = $cpf->complete('043.033.407-');
19         # $cn = '043.033.407-90'
20
21         $cd = $cpf->checkdigit('043.033.407-90');
22         # $cd = '90'
23
24         $bn = $cpf->basenumber('043.033.407-90');
25         # $bn = '043.033.407-'
26

DESCRIPTION

28   ALGORITHM
29       1.  From left to right all digits are multiplied with their position in
30           the sequence.
31
32       2.  The sum of all products is computed.
33
34       3.  The sum of step 2 is taken modulo 11.
35
36           a) If the result is 0 or 1 the checkdigit is 0
37
38           b) otherwise the checkdigit is 11 minus the result.
39
40       4.  The first checkdigit is appended to the number and step 1 to 3 are
41           repeated.
42
43   METHODS
44       is_valid($number)
45           Returns true only if $number consists solely of numbers and the
46           last digit is a valid check digit according to the algorithm given
47           above.
48
49           Returns false otherwise,
50
51       complete($number)
52           The check digit for $number is computed and concatenated to the end
53           of $number.
54
55           Returns the complete number with check digit or '' if $number does
56           not consist solely of digits and spaces.
57
58       basenumber($number)
59           Returns the basenumber of $number if $number has a valid check
60           digit.
61
62           Return '' otherwise.
63
64       checkdigit($number)
65           Returns the checkdigit of $number if $number has a valid check
66           digit.
67
68           Return '' otherwise.
69
70   EXPORT
71       None by default.
72

AUTHOR

74       Mathias Weidner, "<mamawe@cpan.org>"
75

SEE ALSO

77       perl, CheckDigits, www.pruefziffernberechnung.de.
78
79
80
81perl v5.32.1                      2021-01-26Algorithm::CheckDigits::M11_004(3)
Impressum