Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: printing unitialized value of the 'do BLOCK'

by haukex (Archbishop)
on Dec 17, 2019 at 16:08 UTC ( [id://11110293]=note: print w/replies, xml ) Need Help??


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. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110293]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-03-28 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found