in reply to while without parentheses

Define "doesn't work." What platform are you on? Are you on Unix and you're not getting files that don't have dots in the filename?

Or are you in an endless loop because you're using a while instead of a for?

xoxo,
Andy
--
<megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

Replies are listed 'Best First'.
Re: Re: while
by Anonymous Monk on Jul 14, 2001 at 23:14 UTC
    %(~)>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 <*.*>
      (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
      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!!!