I have used a similar block-style before, so I'm going to say that it is sometimes justified. (Look for
redo in the Carp::Heavy shipped in Perl 5.8.) I'd only think that it is justified if you have many conditions that you need to satisfy to leave the loop (my situation there) or else factor the code so that the odd flow of control is compactly presented in an understandable way.
In your case that would mean that you should make A, B, C, etc into functions (hopefully well-named ones) and then write the flow of control in a small block. like this:
EDIT_MAP: {
attempt_edit($map);
redo EDIT_MAP unless can_parse($map);
redo EDIT_MAP unless user_confirms($map);
attempt_edit($reverse_map);
redo EDIT_MAP unless can_parse($reverse_map);
redo EDIT_MAP unless user_confirms($reverse_map);
}
commit_edit($map, $reverse_map);
Now the key flow issues are put somewhere where the
redo logic is very easy to understand and is not intertwined with the grungy details of the steps. It would be easier, for instance, for someone who didn't know the code or technique to look at this and figure out how to add a "give up" option on those
redos, or to have F-H by default fail back to F rather than C.
(Yes, my experience suggests that if someone wants a change in this script, then they are quite likely to want to make them to the flow of control.)
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.