This function takes a credit-card number and returns true if
the number passes the LUHN check.
Ie it returns true if the final character of CHECKSUMMED_NUM is the correct checksum for the rest of the number and false if not. Obviously the final character does not factor into the checksum calculation. False will also be returned if NUM contains in an invalid character as defined by valid_chars(). If NUM is not valid, $Algorithm::LUHN::ERROR will contain the reason.
This function is equivalent to
For example, 4242 4242 4242 4242 is a valid Visa card number, that is provided for test purposes. The final digit is 2, which is the right check digit. If you change it to a 3, its not a valid card number. Ie:
|check_digit NUM||This function returns the checksum of the given number. If it cannot calculate the check_digit it will return undef and set $Algorithm::LUHN::ERROR to contain the reason why.|
By default this module only recognizes 0..9 as valid characters, but sometimes
you want to consider other characters as valid, e.g. Standard & Poors
identifers may contain 0..9, A..Z, @, #, *. This function allows you to add
additional characters to the accepted list.
LIST is a mapping of character => value. For example, Standard & Poors maps A..Z to 10..35 so the LIST to add these valid characters would be (A, 10, B, 11, C, 12, ...)
If you do not provide LIST, this function returns the current valid character map.
Algorithm::CheckDigits provides a front-end to a large collection of modules for working with check digits.
Business::CardInfo provides a class for holding credit card details, and has a type constraint on the card number, to ensure it passes the LUHN check.
Business::CCCheck provides a number of functions for checking credit card numbers.
Regexp::Common supports combined LUHN and issuer checking against a card number.
Algorithm::Damm implements a different kind of check digit algorithm, the Damm algorithm <https://en.wikipedia.org/wiki/Damm_algorithm> (Damm, not Damn).
Math::CheckDigits implements yet another approach to check digits.
I have also written a review of LUHN modules <http://neilb.org/reviews/luhn.html>, which covers them in more detail than this section.
This module was written by Tim Ayers (http://search.cpan.org/search?author=TAYERS).
Copyright (c) 2001 Tim Ayers. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||ALGORITHM::LUHN (3)||2015-11-15|