NAME
Business::PT::BI - Validate Portuguese BI (Bilhete de Identidade)
VERSION
Version 0.02
SYNOPSIS
use Business::PT::BI;
if ( valid_bi($bi, $control_number) ) {
# ...
}
FUNCTIONS
valid_bi
Validates Portuguese BI's.
A Portuguese BI number is comprised by eight digits. Between that number and the "issue" box, the card also has a small box with a single digit. That's the control digit. In order to validate a Portuguese BI, you have to provide valid_bi
with the BI number and the control digit.
valid_bi( $bi, $control_number );
Validation is done as follows:
1) BI is matched with /^\d{8}$/ (eigth consecutive digits with
nothing more)
2) First digit is multiplied by 9, second by 8, third by 7, fourth by
6, fifth by 5, sixth by 4, seventh by 3, eighth by 2
3) All the results of the multiplication are summed
4) Modulo of the sum by 11 is found
5) Complement of the sum by 11 is found
6) Control digit is compared to said complement
Example for BI 12345678, with control digit 9:
1) BI is matched with /^\d{8}/, test passes
2) Multiplication: 1*9, 2*8, 3*7, 4*6, 5*5, 6*4, 7*3, 8*2
3) Sum: 156
4) 156 % 11 = 2
5) 11 - 2 = 9
6) 9 == 9, test passes
When the complement (the result of step 5) is greater than 9, the number is assumed to be 0.
AUTHOR
Jose Castro, <cog at cpan.org>
BUGS
Please report any bugs or feature requests to bug-business-pt-bi at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Business-PT-BI. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Business::PT::BI
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
COPYRIGHT & LICENSE
Copyright 2005 Jose Castro, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.