my $callback_functions = { #I am not suggesting this kind of 1,2,3,4 naming convention in your 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, } };