The Perldocs are a bit fuzzy about the definitions of statement, expression, term

A file is a sequence of statements. A block is a sequence of statements in curlies. A statement can be a flow control statement (if, while, etc), a simple statement (an expression used for its side-effects), as well as other things.

An expression defines the syntax of code required to evaluate to one or more values. For example, an if statement's condition must be an expression.

No one used the word "term". It's a parser rule that usually encompasses variables, literals and sub-expressions in parens. Not a very useful word.

A TERM is a sub-expression inside a statement

No. For example, 1+2 is not a term. An expression inside a statement is an expression (which contains terms).

perlsyn explicitly calls statements "expressions"

No, it doesn't. "The only kind of simple statement is an expression evaluated for its side-effects" is equivalent to "an expression evaluated for its side-effects is a simple statement." In other words, expressions are also statements. For example, print("x") is an expression (so you can do if (print("x")) { ... }), but it can also be used as a statement.

So I hope it's clearer now that the difference is mainly in how something is parsed into the syntax tree.

Both "statement" and "expression" are names of parser rules. As parser rules, there are two differences between them: The syntax they allow, and where they can be used.


In reply to Re^16: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT) by ikegami
in thread printing unitialized value of the 'do BLOCK' by rsFalse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.