in reply to Re^14: printing unitialized value of the 'do BLOCK' (summary)
in thread printing unitialized value of the 'do BLOCK'
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 of Larry's³ standard books showing that it's not an accident.
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
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
°) 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."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^16: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)
by ikegami (Patriarch) on Dec 27, 2019 at 06:16 UTC | |
by LanX (Saint) on Dec 27, 2019 at 17:20 UTC | |
by ikegami (Patriarch) on Dec 28, 2019 at 13:57 UTC | |
by LanX (Saint) on Dec 28, 2019 at 17:20 UTC | |
by ikegami (Patriarch) on Dec 28, 2019 at 17:33 UTC | |
|