Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^6: Can you explain the result?

by PerlOnTheWay (Scribe)
on Dec 06, 2011 at 14:07 UTC ( #942036=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Can you explain the result?
in thread Can you explain the result?

The real problem is that return is pretty different than ordinary subs like open and etc...


Comment on Re^6: Can you explain the result?
Select or Download Code
Replies are listed 'Best First'.
Re^7: Can you explain the result?
by Lotus1 (Chaplain) on Dec 06, 2011 at 14:40 UTC

    How so?

      return affects control flow, which a function in general cannot (leaving Coro aside). Execution after a function returns will always resume right after where the function was called.

      The only built-in function that somewhat affects control flow is exit.

        There are also goto, next, last.

        In the context of the vague assertion I was replying to there is no difference in my opinion. When 'return' is called it does it's job just as when 'open' is called. The difference the OP doesn't seem to grasp is that when return is called, anything after it in that block doesn't execute (how could it?) This is by design and is how other languages work.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2015-07-30 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls