Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl style question: loops with postcondition

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


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2025-05-23 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.