Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: while ()

by Joost (Canon)
on Jun 07, 2005 at 16:39 UTC ( [id://464383]=note: print w/replies, xml ) Need Help??


in reply to while ()

I've never used this construct myself, and tt does seem unintuitive and contrary to perlsynL: "The "while" statement executes the block as long as the expression is true (does not evaluate to the null string "" or 0 or "0"). ".

FYI, the output of deparse (which gets it wrong, occasionally) is:

> perl -MO=Deparse -e 'while () { print "..\n" }' while (1) { print "..\n"; } -e syntax OK

Replies are listed 'Best First'.
Re^2: while ()
by ikegami (Patriarch) on Jun 07, 2005 at 16:54 UTC

    It's not contrary to that quote from perlsyn, because there is no expression to evaluate. That quote simply doesn't apply.

    However, it is contrary to the perlsyn line that says "LABEL while (EXPR) BLOCK", without adding that EXPR is optional.

Re^2: while ()
by blazar (Canon) on Jun 07, 2005 at 16:44 UTC

      I now think that while () deparses as for because while (1) is "optimised" (whatever that means) into for(;;) in perl 5.6.1.

      $ perl561 -MO=Deparse -e 'while(1) {1}' for (;;) { '???'; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found