in reply to Re: Re: Re: Extract potentially quoted words
in thread Extract potentially quoted words

Well, it was a misinterpretation. I guess when I read the line from perlsyn
The only kind of simple statement is an expression evaluated for its side effects.
I twisted it around to "a statement is an expression".

But I think I've got it now: EXPR1 while EXPR2 is a statement, and using || versus or depends on (and affects) what else is in EXPR2, not the full statement.

On the other hand, "do_something() or die" is an expression (which, being evaluated for its side-effects, is also a statement). If the do_something returns 0 or '', the die will be evaluated as part of the expression, not as a statement modifier.

Have I got it right now?

I guess I tripped on the outward similarity of the two, and thought of or as a statement modifier like while and if.

P.S. merlyn, I don't think this is what you wanted to illustrate in your note, but I did learn something valuable. Thanks!

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Extract potentially quoted words
by merlyn (Sage) on Jun 07, 2001 at 17:23 UTC
    Yes, that's exactly what I was pointing at. If you keep "statement" and "expression" separate, it's obvious that "EXPR1 while EXPR2;" is a statement, not an expression, and cannot further be modified, and that "EXPR1 or EXPR2" is still an expression and can be used in a larger expression.

    If you start blurring the concept of "statement" and "expression", you'll be surprised because you start having to use terms like "sometimes" and "mostly". But the rules are actually very obvious once you separate them cleanly.

    -- Randal L. Schwartz, Perl hacker