Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by ikegami (Patriarch)
on Dec 24, 2019 at 14:55 UTC ( [id://11110592]=note: print w/replies, xml ) Need Help??


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

The docs say

If no return is found and if the last statement is an expression, its value is returned. If the last statement is a loop control structure like a foreach or a while, the returned value is unspecified. The empty sub returns the empty list.

The last statement in your example is NOT an expression —it's an unless statement— so the value returned by your block is unspecified. That means you can't count on it being anything. I explained what it normally returns, but as you showed, that doesn't always hold.

So, you can't count on a block ending with an if statement unless statement resulting in something useful or predictable.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found