1Algorithm::CheckDigits(U3spemr)Contributed Perl DocumentAaltgioornithm::CheckDigits(3pm)
2
3
4

NAME

6       Algorithm::CheckDigits - Perl extension to generate and test check
7       digits
8

SYNOPSIS

10         perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods
11
12       or
13
14         use Algorithm::CheckDigits;
15
16         @ml = Algorithm::CheckDigits->method_list();
17         %md = Algorithm::CheckDigits->method_descriptions();
18
19         $isbn = CheckDigits('ISBN');
20
21         if ($isbn->is_valid('3-930673-48-7')) {
22               # do something
23         }
24
25         $cn = $isbn->complete('3-930673-48');     # $cn = '3-930673-48-7'
26
27         $cd = $isbn->checkdigit('3-930673-48-7'); # $cd = '7'
28
29         $bn = $isbn->basenumber('3-930673-48-7'); # $bn = '3-930673-48'
30

ABSTRACT

32       This module provides a number of methods to test and generate check
33       digits. For more information have a look at the web site
34       www.pruefziffernberechnung.de (german).
35

SUBROUTINES/METHODS

37   CheckDigits($method)
38       Returns an object of an appropriate Algorithm::CheckDigits class for
39       the given algorithm.
40
41       Dies with an error message if called with an unknown algorithm.
42
43       See below for the available algorithms. Every object understands the
44       following methods:
45
46       is_valid($number)
47           Returns true or false if $number contains/contains no valid check
48           digit.
49
50       complete($number)
51           Returns a string representation of $number completed with the
52           appropriate check digit.
53
54       checkdigit($number)
55           Extracts the check digit from $number if $number contains a valid
56           check digit.
57
58       basenumber($number)
59           Extracts the basenumber from $number if $number contains a valid
60           check digit.
61
62   Algorithm::CheckDigits::plug_in($module, $description, $prefkey)
63       Register a module that provides the same four methods as above. This
64       function returns a handle with which the registered module can be
65       instantiated.
66
67       The first argument $module is the module to be used for this plugin.
68       This argument is mandatory. Do not register 'Algorithm::CheckDigits'.
69
70       The second argument is a short description of the algorithm. If it is
71       omitted, the string "algorithm of module $module" will be taken.
72
73       The third argument is the preferred key for this algorithm. The
74       plug_in() function does not guarantee to register the algorithm with
75       this key. Instead it returns the key under which the algorithm is
76       registered.
77
78       See "REGISTERING PLUGINS" for more information on registering plugins.
79
80   Algorithm::CheckDigits::method_list()
81       Returns a list of known methods for check digit computation.
82
83   Algorithm::CheckDigits::method_descriptions()
84       Returns a hash of descriptions for the known methods for check digit
85       computations. The keys of the hash are the values returned by
86       method_list().
87
88   Algorithm::CheckDigits::print_methods()
89       Returns a list of known methods for check digit computation.
90
91       You may use the following to find out which methods your version of
92       Algorithm::CheckDigits provides and