in reply to Efficient Rating of Test Answers
And you access the table like so:my %dispatch = ( g6 => \&add_one, g7 => \&add_one, g8 => \&add_one, g9 => \&add_one, g0 => \&add_half, g1 => \&add_half, g2 => \&add_half, g3 => \&add_half, g4 => \&add_half, g5 => \&add_half, k0 => \&add_half, k1 => \&add_half, k2 => \&add_half, k3 => \&add_half, k4 => \&add_half, k5 => \&add_half, ); sub add_one { my $total = shift; $total += 1; return $total; } sub add_half { my $total = shift; $total += 1; return $total; }
This is not a complete solution for you, but it is a start.my $total = 10; $total = $dispatch{'g6'}->($total); $total = $dispatch{'k5'}->($total); print $total, "\n";
---------------------------------------------------- perl -le '$x="jeff";$x++ for(0..4482550);print $x' ----------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Efficient Rating of Test Answers
by Hofmator (Curate) on Aug 14, 2001 at 13:37 UTC | |
by jeffa (Bishop) on Aug 14, 2001 at 19:16 UTC |