Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
P is for Practical
 
PerlMonks  

Re: Perl style question: loops with postcondition

by djantzen (Priest)
on Jun 28, 2002 at 06:12 UTC ( [id://177979]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Perl style question: loops with postcondition

Depends on the purpose of the code.

I think the first is the cleanest way for simple loops of this sort, and I'm reticent to use infinite loops for anything other than long running processes. Setting up a deliberately short-circuited infinite loop for this kind of purpose can work against intelligibility IMO. Labels I use semi-frequently but only in nested loops and switches.

Here's some fun code though:

use Experimental::Exception; do { ..... } while ( try { $thingy->doSomething(); } catch SomeException => sub { return undef; }; )
Update: slight code change to better reflect the nature of the question.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://177979]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.