in reply to Re^4: printing unitialized value of the 'do BLOCK'
in thread printing unitialized value of the 'do BLOCK'

Because it's not an expression. Expressions evaluate to a value, not statements. Of course, Perl has the oddity that a value can be expected from any statement, but you get weird results if the last statement of a sub or do block is such a statement.

The reason it bothered me is that the return value of given is explicitly documented:

When a given statement is also a valid expression (for example, when it's the last statement of a block), it evaluates to: ...

But of course given is experimental, and I thought it would be nice if it was more clearly defined for the backwards-compatible if.

One shouldn't rely on that.

I'm aware of that for for, but not for if. Source?

Replies are listed 'Best First'.
Re^6: printing unitialized value of the 'do BLOCK'
by ikegami (Patriarch) on Dec 17, 2019 at 16:21 UTC

    Sorry, I have updated the post. It should be clearer and less wrong now. :)