This little snippet will validate a passed ABA number. If invoked without an ABA parameter, it will validate a test suite of the 10 possible check-digits. These should all pass.
#!/usr/local/bin/perl use strict; # either pass a potential ABA number, or just invoke without passing # invoking without a passed ABA number will validate the ABA routine i +tself # by reporting all 10 numbers in included test suite (they should all +be valid) my $passed_aba = shift; my @aba_nos; if (length($passed_aba) gt 0 ) { push(@aba_nos,$passed_aba); } else { # the following represents a test suite of the 10 possible configura +tions @aba_nos = qw/ 221012181 231511232 091904513 063100264 051400125 071 +012166 063100277 067006238 063102149 263105250/; } my $aba; for $aba ( @aba_nos ) { if ( aba($aba) ) { print "\n", "$aba is valid"; } else { print "\n", "$aba is not a valid ABA"; } } exit; sub aba { my $EFTABA = shift; my $retval = 0; my $sum = 0; my ($lastpos, $checkdigit, $checksum); my @aba = split(//,$EFTABA); # now do some math using weighing factor # position 1 2 3 4 5 6 7 8 # weight 3 7 1 3 7 1 3 7 $sum += ($aba[0] * 3); $sum += ($aba[1] * 7); $sum += ($aba[2] * 1); $sum += ($aba[3] * 3); $sum += ($aba[4] * 7); $sum += ($aba[5] * 1); $sum += ($aba[6] * 3); $sum += ($aba[7] * 7); # now the total gets subtracted from the next highest multiple of 10 # (just subtract the last digit from 10....) # print "\nSum: $sum"; $lastpos = length($sum); $checkdigit = substr($sum,($lastpos-1),1); # print "\nCheckdigit: $checkdigit"; $checksum = ( 10 - $aba[8] ); if ( $checksum eq 10 ) # 10 = 0 { $checksum = 0; } if ( $checksum eq $checkdigit ) { $retval = 1; #print "\n$EFTABA is a valid ABA number"; } return $retval; }

In reply to ABA validator by wardk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.