Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: eval and goto: no worky?

by BrowserUk (Patriarch)
on Nov 09, 2010 at 23:22 UTC ( [id://870428]=note: print w/replies, xml ) Need Help??


in reply to eval and goto: no worky?

There is no need to use eval with goto:

sub f1{ print 'f1'} sub f2{ print 'f2' } sub f{ goto &{$_[0]} };; f('f1');; f1 f('f2');; f2 f('f');; ### Warning infinite loop!

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: eval and goto: no worky?
by saintmike (Vicar) on Nov 10, 2010 at 02:09 UTC
    Actually, my goal was to define a wrapper function that could never die(), even if the inner function did and expose this new interface to the user.

    The advantage of using 'goto' would have been that the caller level in the inner function would have been unchanged, but I worked around the Perl limitation of not offering goto &NAME with eval {} by adding some code to adapt the caller level manually at the application level.

    Thanks, all!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-29 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found