Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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??

in reply to do/redo or for(;;): what's Kosher?

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.

Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Comment on Re: do/redo or for(;;): what's Kosher?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://136035]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2015-11-29 07:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (749 votes), past polls