Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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??


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 - mneylon-pm@masemware.com || "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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-21 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls