Business::PT::BI version 0.01 ============================= =head1 NAME Business::PT::BI - Validate Portuguese BI (Bilhete de Identidade) =head1 VERSION Version 0.01 =head1 SYNOPSIS use Business::PT::BI; if ( valid_bi($bi, $control_number) ) { # ... } =head1 FUNCTIONS =head2 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 C 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. =head1 AUTHOR Jose Castro, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Business::PT::BI You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 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.