|
CheckDigits::M11_004 - compute check digits for CPF |
CheckDigits::M11_004 - compute check digits for CPF (BR), Título Eleitoral (BR)
use CheckDigits;
$cpf = CheckDigits('cpf');
if ($cpf->is_valid('043.033.407-90')) {
# do something
}
$cn = $cpf->complete('043.033.407-');
# $cn = '043.033.407-90'
$cd = $cpf->checkdigit('043.033.407-90');
# $cd = '90'
$bn = $cpf->basenumber('043.033.407-90');
# $bn = '043.033.407-'
=head1 DESCRIPTION
a) If the result is 0 or 1 the checkdigit is 0
b) otherwise the checkdigit is 11 minus the result.
is_valid($number)$number consists solely of numbers and the last digit
is a valid check digit according to the algorithm given above.
Returns false otherwise,
complete($number)$number is computed and concatenated to the end
of $number.
Returns the complete number with check digit or '' if $number
does not consist solely of digits and spaces.
basenumber($number)$number if $number has a valid check
digit.
Return '' otherwise.
checkdigit($number)$number if $number has a valid check
digit.
Return '' otherwise.
None by default.
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
the perl manpage, the CheckDigits manpage, www.pruefziffernberechnung.de.
|
CheckDigits::M11_004 - compute check digits for CPF |