Thank you everyone for answers, now it became more clear. As I understand, every statement in Perl "returns" a value -- rather, it can be evaluated if program flow requires it. The bare "next;" is a statement. What it evaluates to is never necessary to know. The "foo unless bar;" is a statement, too. If "bar" is false, it obviously evaluates to "foo". But if "bar" is true, this whole statement, unexpectedly to me as of yesterday, evaluates to "bar":
>perl -wE "$x=33; say do{42 unless $x}" 33
The (wrong) intuition was that result would be something like "undef". But, if I get RonW's explanation right, the "evaluator" is more straightforward and "primitive" -- it doesn't try to "understand" statement as a whole, but whatever subexpression was evaluated last is taken as result for a whole.
In reply to Re^2: Abuse of "or next" in expressions and "next" that returns value
by vr
in thread Abuse of "or next" in expressions and "next" that returns value
by vr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |