If you want to keep your sanity while programming,
Highly desirable. :)
you'll encode all of the nesting logic into a data structure,
Any chance I could get you to give a short example of such a data structure?
and all the code blocks marked with #... in your example into a dispatch table.
Hm. Haven't used dispatch tables before. Searching around a bit, it seems to be just a hash where the keys are "command" names and the values are references to functions. Will have a closer look at "When should I use a dispatch table?" and "Implementing Dispatch Tables", because I'm still not sure what it buys me over just calling the functions directly.
Then you write a small dispatching program that walks through the data structure, prints the prompt, analyses the results, makes a transition into the next state and calls your callback (maybe in a different order).
Oooh. Would love to see pseudocode if you were of a mind to take the time to write it out.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||