Business::HK::IdentityCard - validate identity card numbers used in Hong Kong
version 1.000
use Business::HK::IdentityCard; my $hkid = Business::HK::IdentityCard->new('A123456(3)'); if ($hkid->is_valid()) { print $hkid->as_string() . " is valid\n"; }
This module validates identity card numbers used in Hong Kong. See http://en.wikipedia.org/wiki/Hong_Kong_Identity_Card for further details on the format.
Accepts a scalar representing the ID. IDs look like A123456(3), ie an alphabetic prefix, siz digits and a check digit. The prefix can be one or two characters and the brackets are optional for the check digit.
A123456(3)
Returns true if the ID provided is a correct HK ID. This will confirm that the format is correct and the checksum is valid.
Returns the ID formatted as a string using the conventional format, ie upper-case letters and checksum in brackets.
Returns the ID formatted as a string without the checksum. As the checksum is not officially part of the ID, some systems may store IDs in this format.
Source code can be found on Github. Pull requests for bug fixes welcome.
http://github.com/rupertl/business-hk-identitycard/tree/master
Thanks to David Webb for advice on how the checksum for double prefix IDs should be calculated.
Rupert Lane <rupert@rupert-lane.org>
This software is copyright (c) 2014 by Rupert Lane.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Business::HK::IdentityCard, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Business::HK::IdentityCard
CPAN shell
perl -MCPAN -e shell install Business::HK::IdentityCard
For more information on module installation, please visit the detailed CPAN module installation guide.