Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by paulbort (Hermit)
on Jan 04, 2002 at 23:23 UTC ( #136351=note: print w/ replies, xml ) Need Help??


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

I know it's more code, but my favorite method for obvious loops looks like this:

$forever = 1; while ($forever) { ... }
---
Spring: Forces, Coiled Again!


Comment on Re: Re: do/redo or for(;;): what's Kosher?
Download Code
Replies are listed 'Best First'.
Re: Re: Re: do/redo or for(;;): what's Kosher?
by Juerd (Abbot) on Jan 05, 2002 at 00:08 UTC
    That won't be optimized away, but a constant true value (not 0, "0", "" or undef) are.
    This means you can have less code and more efficiency, but still the clarity you like:
    while ('forever'){ ... }


    Which is equivalent to while (1) { ... }, which is optimized to for (;;) { ... }.

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-08-31 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (352 votes), past polls