The syntax for the suffix notation is
EXPR while EXPR;
and not
EXPR while ( EXPR );
Therefore, you are comparing apples and oranges.
In while() { print "1\n" }, the expression is "".
In print "1\n" while ();, the expression is "()", the empty list, which is false in boolean context.
You're right about there being an inconsistency, though, just not the one you mentioned.
>perl -MO=Deparse -e"while() { print 1 }"
while (1) {
print 1;
}
-e syntax OK
>perl -MO=Deparse -e"print 1 while;"
syntax error at -e line 1, at EOF
-e had compilation errors.
|