Hanken has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to represent complex data structure and manipulate it easily?
by roboticus (Chancellor) on Jun 19, 2012 at 02:51 UTC | |
Re: How to represent complex data structure and manipulate it easily?
by NetWallah (Canon) on Jun 19, 2012 at 05:21 UTC | |
Re: How to represent complex data structure and manipulate it easily?
by Anonymous Monk on Jun 19, 2012 at 03:04 UTC | |
Re: How to represent complex data structure and manipulate it easily?
by linuxkid (Sexton) on Jun 19, 2012 at 20:26 UTC | |
by Boldra (Curate) on Jun 21, 2012 at 07:16 UTC | |
by linuxkid (Sexton) on Jun 21, 2012 at 14:13 UTC |