|
|
| Perl Monk, Perl Meditation | |
| PerlMonks |
Re: do/redo or for(;;): what's Kosher?by Masem (Monsignor) |
| on Jan 03, 2002 at 22:45 UTC ( #136035=note: print w/ replies, xml ) | Need Help?? |
|
There's certainly nothing wrong with that block structure; as you mentioned, there's multiple ways to set up such a block in perl. As for 'repenting', I think you need to simply judge if a block style set up as a infinite loop is best, or if a block style set up as a very long but not infinite loop is better, and this is a matter of perl style. For example, if my program is continuously accepting user input, I'd consider that as a infinite loop and thus would make sense for a do-last if-redo block. On the other hand, if I'm reading in a data file, which has some fixed size though may be in the gigs, I'd use a while or similar loop to handle it. But, consider your audience for the code; if it's your workplace, make sure that the structure is understood before converting everything over to that. Make sure to comment well because if there's a lot of ccode between the two braces, it'll look like a bare block instead of a control structure; ideally, that type of block should only last a few lines as to be able to see the redo at the end while viewing the top brace. If this is a problem, there are other control structures that effectively do the same thing.
-----------------------------------------------------
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||