[Omaha.pm] Tight code - Amtrak

Jay Hannah jhannah at omnihotels.com
Thu Jan 26 11:28:47 PST 2006


Wow. There's some tight code... By comparison, our version of this
written in the scripting language "Informix 4GL" is 93 lines long. And
broken. :)

j


=head2 is_2v_ff_id

This method validates an Acela (Amtrak) "frequent train rider" program.

  Usage: $self->is_2v_ff_id("123949050");

=cut

sub is_2v_ff_id {
  my $primary_acct_num = $_[1];
  return 0 unless $_[0]->is_int($primary_acct_num);
  my ($offset,$total) = (0,0);
  for (reverse  split//,$primary_acct_num) {
    for my $i (split //,($_ * ($offset++ %2 + 1))) { $total+=$i}
  }
  return not $total % 10;
}




More information about the Omaha-pm mailing list