'Major task to perform?' => ['task_1','task_2','task_2'], #### 'Major task to perform?' => { answers => [ 'Add', 'Delete', 'Rename' ], keys => [ 'task_1','task_2', 'task_2' ], }, #### my $current_key = 'Major task to perform?'; while ( my $choice = prompt( $current_key, ...)) { # set INDEX to offset of $choice in $structure{ $current_key }{answers} # if $structure{$current_key}{keys}[INDEX] is empty # break out of loop; you;'re in a terminal state # else $current_key = $structure{$current_key}{keys}[INDEX] }

A lot of the code is left as an exercise to the reader. Good luck with your class.