Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: eval and goto: no worky?

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


in reply to eval and goto: no worky?

Perl tells you "Can't goto subroutine from an eval-block".

You ask Perl to catch errors, then you ask Perl to replace the currently running function with another, but it can't continue to catch errors if it's no longer running. Given conflicting instructions, Perl lets you know you have something to fix.

Update: Substituted the explanation with a much clearer version.

Replies are listed 'Best First'.
Re^2: eval and goto: no worky?
by saintmike (Vicar) on Nov 09, 2010 at 23:02 UTC
    Interesting, I didn't see a warning with warnings and strict on. Did you find that in the documentation?
      foo( "a" ); sub foo { eval { goto &foo2; } or warn $@; } sub foo2 { print "foo2 called with @_\n"; } __END__ Can't goto subroutine from an eval-block at - line 4.
      It's not a warning, it's a fatal error. You successfully caught the error and subsequently ignored it. An Anonymous Monk shows how you could actually look at the error you are hiding.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2026-03-07 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.