Hi Dear Perl Experts,

I got a problem about how to represent a complex data structure in perl. Here is a rough introduction of my data:
(1) the data consist of several commands: cmd00, cmd01, cmd02... And each command has a respective table;
(2) the table has 3 elements: initial state, feedback and end state;
(3) initial state could be any subset of {idle, start, jump, halt}; for each initial state, feedback has to pick up one from number (0 .. 3);
(4) each initial state and feedback have a certain relative end state which is also within {idle, start, jump, halt}; end state could be more than one elements;

Graphically and strictly, it is showed as below:

`Command Initial state. Feedback. E
+nd state
cmd00. Idle 0.
+ Idle or start
1.
+ Start
Start. 0.
+ Jump
3.
+ Halt or start
2.
+ Idle
cmd01 Idle 0.
+ Idle or start
1.
+ Jump
Jump 0.
+ Halt or idle
1.
+ start
2.
+ Idle
cmd02. .......
......
`

My target:
I need a function like sub get_endstate_by_cmd($cmd, $default_state); I will send a random sequence of commands to the sub routine in which initial state and feedback will be randomized in their legal range, then it returns the end state for next iteration.
The difficulties are: 1. To represent the data; 2. To randomize in a legal range;
Could anyone give me some hints?

Comment onHow to represent complex data structure and manipulate it easily?DownloadCode