There is one thing you can do to make your program structure really neat, and that is to use a HoH (also could be AoA, AoH or whatever two-level sturcture that fits) to store your call back functions.
Give each of your question a unique identifier, could be a number or a string. Also give each of your choices an identifier, which is unique within the related question.
To demo, I just use string as identifier, and pick HoH as the structure. I can store all the callback functions in this way:
my $callback_functions =
{
#I am not suggesting this kind of 1,2,3,4 naming convention in you
+r actual code, this is just for demo, it is never a good idea to hard
+ code the index as part of your identifier.
"question1" => {
"answer1" => \&func1,
"answer2" => \&func2,
"answer3" => \&func3,
},
"question2" => {
"answer1" => \&func4,
"answer2" => \&func5,
"answer3" => \&func6,
},
"question3" => {
"answer1" => \&func7,
"answer2" => \&func8,
"answer3" => \&func9,
}
};
But you better use some meaningful identifiers.
By doing this, you can actually avoid those tedious nested if-else, and make your logic much more straight and clear. Now the differences among questions and answers is detached from your logic, and is largely contained in that callback structure.