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 (;;) { '???'; }