NAME
Business::DK::CVR - a danish CPR code generator/validator
VERSION
This documentation describes version 0.01
SYNOPSIS
use Business::DK::CPR qw(validate);
my $rv;
eval {
$rv = validate(1501721111);
};
if ($@) {
die "Code is not of the expected format - $@";
}
if ($rv) {
print "CPR is valid";
} else {
print "CPR is not valid";
}
use Business::DK::CPR qw(calculate);
my @cprs = calculate(150172);
my $number_of_valid_cprs = calculate(150172);
DESCRIPTION
CPR stands for Central Person Registration and it a social security number used in Denmark.
validate
This function checks a CPR number for validity. It takes a CPR number as argument and returns 1 (true) for valid and 0 (false) for invalid.
It dies if the CPR number is malformed or in anyway unpassable, be aware that the 6 first digits are a date (SEE: _checkdate function below.
NB! it is possible to make fake CPR number, which appear valid, please see MOTIVATION and the calculation function.
calculate
This function takes an integer representing a date and calculates valid CPR numbers for the specified date. In scalar context returns the number of valid CPR numbers possible and in list context a list of valid CPR numbers.
If the date malformed, in anyway not valid or unspecified the function dies.
PRIVATE FUNCTIONS
_checkdate
This function takes an integer representing a date in the format: ddmmyy.
It check the validity of the date and returns 1 (true) if the date is valid.
It dies if no argument is provided or if the data in invalid or cannot be parsed.
EXPORTS
Business::DK::CPR exports on request:
TODO
- The CPR agency in Denmark are developing a new CPR scheme, due to the fact that they are running out of valid CPR numbers.
TESTS
Coverage of the test suite is at 100%
BUGS
Please report issues via CPAN RT:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Business-DK-CPR
or by sending mail to
bug-Business-DK-CPR@rt.cpan.org
SEE ALSO
MOTIVATION
I write business related applications. So I need to be able to validate CPR numbers once is a while, hence the validation function.
The calculate function is a completely different story. When I was in school we where programming in Comal80 and some of the guys in my school created lists of CPR numbers valid with their own birthdays. The thing was that if you got caught riding the train without a valid ticket the personnel would only check the validity of you CPR number, so all you have to remember was your birthday and 4 more digits not being the 4 last digits of your CPR number.
I guess this was the first hack I ever heard about and saw - I never tried it out, but back then it really fascinated me and my interest in computers was really sparked.
AUTHOR
Jonas B. Nielsen, (jonasbn) - <jonasbn@cpan.org>
COPYRIGHT
Business-DK-CPR is (C) by Jonas B. Nielsen, (jonasbn) 2006
Business-DK-CPR is released under the artistic license
The distribution is licensed under the Artistic License, as specified by the Artistic file in the standard perl distribution (http://www.perl.com/language/misc/Artistic.html).