Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by rsFalse (Chaplain)
on Dec 22, 2019 at 23:29 UTC ( [id://11110525]=note: print w/replies, xml ) Need Help??


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

I'm not sure I understand. But nevermind.
  • Comment on Re^11: printing unitialized value of the 'do BLOCK'

Replies are listed 'Best First'.
Re^12: printing unitialized value of the 'do BLOCK'
by ikegami (Patriarch) on Dec 24, 2019 at 14:55 UTC

    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://11110525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found