PrePAN

Sign in to PrePAN

Algorithm::Damm Damm check digit calculation

Good

Synopsis

Implement the Damm check digit algorithm

Description

See http://en.wikipedia.org/wiki/Damm_algorithm for details on this algorithm.

A couple of questions:

1) Is this a good namespace?

2) Any blatant issues found?

Comments

anonymouse
Anonymous
namespace sounds right. the wikipedia article says it's similar to the Verhoeff algorithm, which has an implementation in the same namespace: http://search.cpan.org/dist/Algorithm-Verhoeff/
Released to CPAN: https://metacpan.org/release/MLX/Algorithm-Damm-1.000.

Review comments still very welcome :-)
I'd first modify the interface to match with https://metacpan.org/module/Algorithm::CheckDigits#CheckDigits-method (is_valid, complete, checkdigit, and basenumber), second allow both calling as function (`Algorithm::Damm::is_valid($number)`) and as method (`Algorithm::Damm->is_valid($number)` and $a->is_valid($number)` if you add a constructor `Algorithm::Damm->new`), and third rename it to `Algorithm::CheckDigit::Damm`. You could further ask Mathias Weidner, author of Algorithm::CheckDigits to implement a plugin mechanism, so `Algorith::CheckDigits->new('Damm')` loads your module.
Figures that I didn't wait long enough for comments before cpanning it :-)

Suggestions make sense. I will see if I can get a few properly shaped tuits to implement in the next few days.

Wonder how I missed the entire Algorithm::CheckDigits stuff.

--Brian
The good about Perl: everyone can write a CPAN module, so you most likely find a module for your problem. The bad about Perl: everyone writes CPAN modules, so you unlikely find the right module for your problem.

Please sign up to post a review.