in reply to Efficient Rating of Test Answers

“The possible letters are: O, B, A, F, G, K and M (in order of ascension).” What happened to R and N?

The easiest code I can think of is to map the designation to a scalar, and then use ordinary numeric ranges to compare.

$answer =~ tr/OBAFGKM/1234567/; if ($answer >= 56 && $answer <= 59) ...
Spanning letters is not an issue.

Now, you have a lot of the same code but just changing the ranges. Make it into a table, like so:

@results= ( undef, #index 0 unused [ #describe question 1 qw/ g0 k5 g6 g9/ ], # another row for each question.
This lists the half-right range, then the full-right range. The code can extract these 4 values, convert them to numbers, test for full-right first (being a subset), then the larger half-right range, all with one block of code.

—John