![]() |
|
Think about Loose Coupling | |
PerlMonks |
Re: Iteration condition...by radiantmatrix (Parson) |
on Mar 31, 2008 at 19:50 UTC ( [id://677627]=note: print w/replies, xml ) | Need Help?? |
I don't know about "shorter, more economical", but perhaps easier to maintain:
That's a very simple state machine that uses a dispatch table. It's pretty easy to expand: add transitions to the @transition structure, write a sub for each operation and add it to the %operation dispatch table. You don't need to change any other code. However, if you have a large number of states and/or transitions, using one of the state-machine modules that CountZero references above could be a better choice.
<–radiant.matrix–>
Ramblings and references The Code that can be seen is not the true Code I haven't found a problem yet that can't be solved by a well-placed trebuchet
In Section
Seekers of Perl Wisdom
|
|