http://www.perlmonks.org?node_id=695416


in reply to Re: General pattern for interactive text-mode script?
in thread General pattern for interactive text-mode script?

Could you please give an example of such a data structure? Is it anything like the following? :

#!/usr/bin/env perl use strict; use warnings; #... sub task_1_a_1 { print "Performing task 1 a 1 ...\n"; } #... my %stuff = ( 'Major task to perform?' => ['task_1','task_2','task_2'], 'task_1' => {'Sub-task for task_1?' => ['task_1_a','task_1_b','tas +k_1_c']}, 'task_2' => {'Sub-task for task_2?' => ['task_2_a','task_2_b','tas +k_2_c']}, 'task_3' => {'Sub-task for task_3?' => ['task_3_a','task_3_b','tas +k_3_c']}, 'task_1_a' => {'Sub-sub-task for task_1_a?' => ['task_1_a_1','task +_1_a_2']}, #... 'task_1_a_1' => \&task_1_a_1, ); $stuff{task_1_a_1}->();

Incidentally, if you happen to know of a simple example of a FSM (preferably implemented in Perl), I'd love to see it.