more useful options | |
PerlMonks |
Re^15: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)by LanX (Saint) |
on Dec 26, 2019 at 14:48 UTC ( [id://11110632]=note: print w/replies, xml ) | Need Help?? |
The Perldocs are a bit fuzzy about the definitions of
They start after a semicolon and end with a semicolon, unless:
A TERM is a sub-expression inside a statement. That's roughly everything you can put into round parens and terms can be nested. This corresponds to a branch or leaf in the op tree. In order to use a statement as a term, Perl offers the do {BLOCK} syntax. Other possibilities are sub and eval . Since statements are otherwise bound to be executed in void context (after a semicolon), we use them for their side effects and don't expect them to return (meaningful) values. But some do, like if .
You've even cited a passage from one EXPRESSION is a general concept,
I think part of the confusion comes from Larry using C syntax mixed with Lisp semantics. Disclaimer: I didn't have time to check all canonical Perldocs and sometimes it's not clear if an english word was used in its general meaning or to denote a Perl concept. ( like "Expressions are expressions", "and and or are operators", and so on...)
Cheers Rolf
footnote°) I probably misread perlop here, my tests don't allow to write a statement into [] or {} ²) multiple statements per line or multi-line statements break the mental analogy ³) ERRATA: rsFalse informed me that "Intermediate Perl was written by Schwartz and others, not including Larry."
In Section
Seekers of Perl Wisdom
|
|