# untested use strict; my %questions = ( 1 => { question => "Who's Perl's top dog?", answer => "Larry Wall" }, 2 => { question => "What's the answer?", answer => "42" }, ); foreach my $question (sort {$a <=> $b} keys %questions) { my $guess = param("$Q$question"); print "$question). You answered: $questions{$question}{question} with $guess. "; if ($guess eq $questions{$question}{answer}) { print q|Correct
|; } else { print q|Incorrect
|; } } # keeping totals left as homework =)