in reply to eval doesn't work under tkx

Try resetting $@ after handling the error condition, or localizing $@ to the scope of the while-loop where your eval is called.

You could also add a local $SIG{__DIE__} to that scope and have the handler output a stacktrace to see what happens. If that handler isn't called, your program is dying somewhere else from leftovers of the failed call - again, I guess that's related to $@.

Replies are listed 'Best First'.
Re^2: eval doesn't work under tkx
by nyj (Novice) on Jul 16, 2010 at 05:56 UTC
    Hi and thanks for replying. I don't know what you mean by 'resetting $@' . . . also, I'm certain that the code never gets to the error handler. If I put 'print' statements around the 'execute' part of it, like
    print "hi" $sth->execute(); print "bye"
    I'll only get "hi" as output. If I put a print statement inside the error handler, it doesn't show. But if I invoke the function without the Tkx, it works fine. I swear, the only difference between it working and not working is the presence or absence of the Tkx loop, which is in another module - the code I've shown you earlier is identical in both cases.

      I mean the following:

      while ($sqlSuccess == 0) { eval { ... }; if ($@) { my $errString = $@; $@ = ''; # <-- here print $fileHandle "caught error $errString\n"; ... } }
        Thanks for your reply - I've been parsing the sql statement and doing a 'drop table' in the meantime, but I'll try your suggestion. Thanks again