[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Tight code - Amtrak



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;
}