Tina Müller > Business-DE-KontoCheck-0.12 > Business::DE::KontoCheck



Annotate this POD

View/Report Bugs
Module Version: 0.12   Source  


Business::DE::KontoCheck - Validating Bank-Account Numbers for Germany


I won't implement other methods and I won't update old ones. This is too time consuming for me. Anyone who likes to do this, please contact me.

This is just a release to note the above.

I might develop the interface to get the bank name for a bank number, though.

The included blz file is also not uptodate. The format of the file hash changed since June 5th, 2006.


    use Business::DE::KontoCheck;
    my $kcheck = Business::DE::KontoCheck->new(
        BLZFILE => "path/to/blzpc.txt",
    my $konto = $kcheck->get_info_for_blz($blz);
    # $konto is a Business::DE::Konto
    my $bankname = $konto->get_bankname;


  use Business::DE::KontoCheck;
  my $kcheck = Business::DE::KontoCheck->new(%hash);

  where %hash can have zero, one or more of the following entries:
  BLZFILE => '/path/to/BLZ.dat'
  MODE_BLZ_FILE => 'BANK' # either 'BANK', 'POST' or 'MINIMAL'


  my $kcheck = Business::DE::KontoCheck->new(
    BLZFILE => '/path/to/BLZ.dat',
  If the BLZ-file is from POSTBANK, MODE_BLZ_FILE has to be 'POST'.
  If the file is from the BUNDESBANK, it'S 'BANK'.
  Set MODE_BLZ_FILE to 'MINIMAL' if you have a converted BLZ-file
  (see below at Section "CACHING, SPEED-UPS")

  my $konto = $kcheck->check(%hash);
  # where %hash can have zero, one or more of the following entries:
  # BLZ     => 12345678
  # KONTONR   => 1234567890
  # e.g.:
  my $konto = $kcheck->check(BLZ => 12345678, KONTONR => 1234567890);
  if (my $res = $konto->check(%hash)) {
    # BLZ/account-number is okay
  elsif (!defined $res) {
    # account number is invalid
  else {
    # there were some other errors

  check() returns 1 for success and 0 or undef for failure.
  If the input was okay but the account number is invalid it
  returns undef; in case of any other error it returns 0.
  So you should check
  In case of
  failure you can do $konto->printError() to see why it failed.
  Alternatively you can get errorcodes with:

-------------------------------------------- my $errors = $konto->getErrors(); # reference to list of errors Here's the list of errors:

  ERR_NO_BLZ      => Please supply a BLZ'
  ERR_BLZ         => Please suplly a BLZ with 8 digits'
  ERR_BLZ_EXIST   => BLZ doesn't exist'
  ERR_BLZ_FILE    => BLZ-File corrupted'
  ERR_NO_KNR      => Please supply an account number'
  ERR_KNR         => Please supply a valid account number with only digits'
  ERR_KNR_INVALID => Account-number is invalid'
  ERR_METHOD      => Method not implemented yet'



If this script is running as a daemon or within mod_perl it would be rather slow because it has to read in the BLZ-file every time. You can speed this up by either doing:

  $Business::DE::KontoCheck::CACHE_ON = 1; # DEFAULT is 1
  This caches a BLZ, so if this BLZ is asked for a second
  time the file doesn't have to be opened.


  $Business::DE::KontoCheck::CACHE_ALL = 1; # DEFAULT is 0
  This will read the whole BLZ-file at startup (when creating a
  new Business::DE::KontoCheck-Object) and will
  cache the method for every BLZ, so that the file will
  not be opened any more.
  The hash which holds the cached BLZs will have about
  5000 entries at the moment.

  So if you run this within mod_perl, for example, you can do
  at startup:
  use Business::DE::KontoCheck;
  $Business::DE::KontoCheck::CACHE_ALL = 1;
  my $kcheck = Business::DE::KontoCheck->new(
    BLZFILE => "path/to/blzpc.txt",
  and then make this $kcheck-Object available for the apache-childs
  and call:
  my $konto = $kcheck->check(BLZ=>$blz, KONTONR=>$kontonr);
  if (my $res = $konto->check()) {

  You also have the possibility to make the BLZ-file much smaller
  (about 2% of the size) by using the tools/convert.pl script.
  Just call the script to get instructions.
  If you are using this file as BLZ-source, the MODE_BLZ_FILE
  has to be: 'MINIMAL'.
  my $kcheck = Business::DE::KontoCheck->new(
    BLZFILE => "path/to/blzpc_converted.txt",
        Then you don't have to use one of the caching methods described
  above. This requires the Storable-Module.


  Beside checking a BLZ/AccountNo. there are the following
  methods available:
getMethod2BLZ (BLZ)
    Returns the Check-method for that BLZ.
    my $method = $kcheck->getMethod2BLZ($blz);
    Returns the method (element in "00".."A1").
    If the BLZ doesn't exist, it returns undef.

Creates a Business::DE::Konto object and checks if account number is valid. This method should not be used as not all check methods are implemented.


The Constructor.

    my $kcheck = Business::DE::KontoCheck->new(
        BLZFILE => "path/to/blzpc.txt",
    my $konto = $kcheck->get_info_for_blz($blz);
    my $bankname = $konto->get_bankname;

See Business::DE::Konto for other methods.


None by default. All methods are accessed over the object.


Version 0.09


Tina Mueller (see http://tinita.de/projects/perl/en)



syntax highlighting: