Jenda writes: > Well ... what about just ... making the eval{} block smaller? > > eval { > # Code where an error may occur > exception_causing_method(); > }; > if ($@) { ... } > # Code where I want to resume after handling the exception > print "Continuing....\n";
Let's assume I'm trying to write a generalized resumptive error handler. I don't have control over what the eval block (or equivalent) will be, nor do I know how to modify its contents. > Another thing ... what EXACTLY do you mean by "resume with > next statement". Say your eval{} block called function Foo(), which > called Bar(). And somewhere in the middle of Bar() occured an > exception.Do you want to continue with Bar(). Go back into Foo() > just below he call to Bar()? Go to the line of the eval{} block below > the call to Foo() ? > I guess the last one, but ... The first: continue with the next line after where the exception was triggered, such that all state in any current functions is the same. > Anyway to tell the truth you could do this : > > eval { > print "Ahoj\n"; > $y = 0; > $x = 1/$y; > LEJBL: print "Cau\n"; > }; > if ($@) { > print "ERROR: $@\n"; > goto LEJBL; > } That's closer, but is it possible without inserting a label or using a goto? Assume the code that might trigger the error (the eval block or equivalent) is given to me. > P.S.: You come from VB? "On Error Resume Next", "On Error > Goto errHandler" and "Resume Next" ... I've never got used to that > crazy way of doing things. No, I've never used VB. I'm just looking into doing resumptions in Perl.... + Richard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]