in reply to Re: while
in thread while without parentheses

%(~)>perl testwhile syntax error at t line 1, near "while <*.*>" syntax error at t line 4, near "}" Execution of t aborted due to compilation errors. %(~)>
I get that response when I try to run the script without the parenthesis around the <*.*>

Replies are listed 'Best First'.
Re: Re: Re: while
by msemich (Novice) on Jul 16, 2001 at 19:03 UTC
    (Be warned, newbie here) I was under the impression that the literal definition of a while structure in Perl was defined in the parser as the while keyword-a parenthesized statement (that is itself further defined as any returning object, or some such) and a loop body that is delimited by curlies. Of course, there is a little rider to that that states that in some cases exceptions can be made assuming that there is no ambiguity in the current context. I would imagine that there is some ambiguity associated with a while <*.*> construct in the parser...otherwise I have been told that it would work. It could be a precedence problem, considering that the parens kick the precedence for the token up quite a bit. Course, I'm a newbie so take all of this for what you paid for it MSemich
Re: Re: Re: while
by mikeo (Initiate) on Jul 16, 2001 at 18:25 UTC
    The issue is one of syntax.

    Perl's syntax expects the body of the while conditional to be wrapped in parenthesis. This allows it to be read by others, including the interpreter. Every language has a syntax to make it understandable to multiple people. The English language, for example expects the first character of each sentence to be capitalized, a period (or some other form of punctuation...) at the end of each sentence, and spaces between words.

    itdbealothardertoreadifiwrotelikethis!!!