Algorithm-CheckDigits

 view release on metacpan or  search on metacpan

lib/Algorithm/CheckDigits.pm  view on Meta::CPAN

    }
}    # print_methods()

sub AUTOLOAD {
    my $self = shift;
    my $attr = $AUTOLOAD;
    unless ( $attr =~ /^Algorithm::CheckDigits::[A-Za-z_0-9]*$/ ) {
        croak "$attr is not defined";
    }
    return '';
}    # AUTOLOAD()

sub DESTROY {
}

# Preloaded methods go here.

1;
__END__

=head1 NAME

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

=head1 SYNOPSIS

  perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods

or

  use Algorithm::CheckDigits;
  
  @ml = Algorithm::CheckDigits->method_list();
  %md = Algorithm::CheckDigits->method_descriptions();

  $isbn = CheckDigits('ISBN');

  if ($isbn->is_valid('3-930673-48-7')) {
	# do something
  }

  $cn = $isbn->complete('3-930673-48');     # $cn = '3-930673-48-7'

  $cd = $isbn->checkdigit('3-930673-48-7'); # $cd = '7'

  $bn = $isbn->basenumber('3-930673-48-7'); # $bn = '3-930673-48'

=head1 ABSTRACT

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

=head1 SUBROUTINES/METHODS

=head2 CheckDigits($method)

Returns an object of an appropriate Algorithm::CheckDigits class for the
given algorithm.

Dies with an error message if called with an unknown algorithm.

See below for the available algorithms. Every object understands the following
methods:

=over 4

=item is_valid($number)

Returns true or false if C<$number> contains/contains no valid check digit.

=item complete($number)

Returns a string representation of C<$number> completed with the appropriate
check digit.

=item checkdigit($number)

Extracts the check digit from C<$number> if C<$number> contains a valid check
digit.

=item basenumber($number)

Extracts the basenumber from C<$number> if C<$number> contains a valid check
digit.

=back

=head2 Algorithm::CheckDigits::plug_in($module, $description, $prefkey)

Register a module that provides the same four methods as above. This function
returns a handle with which the registered module can be instantiated.

The first argument C<$module> is the module to be used for this plugin. This
argument is mandatory. Do not register 'Algorithm::CheckDigits'.

The second argument is a short description of the algorithm. If it is omitted,
the string C<algorithm of module $module> will be taken.

The third argument is the preferred key for this algorithm. The C<plug_in()>
function does not guarantee to register the algorithm with this key. Instead
it returns the key under which the algorithm is registered.

See L</"REGISTERING PLUGINS"> for more information on registering plugins.

=head2 Algorithm::CheckDigits::method_list()

Returns a list of known methods for check digit computation.

=head2 Algorithm::CheckDigits::method_descriptions()

Returns a hash of descriptions for the known methods for check digit
computations. The keys of the hash are the values returned by
C<method_list()>.

=head2 Algorithm::CheckDigits::print_methods()

Returns a list of known methods for check digit computation.

You may use the following to find out which methods your version of
Algorithm::CheckDigits provides and where to look for further



( run in 1.931 second using v1.01-cache-2.11-cpan-5735350b133 )