Hello fellow celibates . . . I have a problem I can't find the answer to anywhere else, I hope someone can help. I have the following piece of code:
# We put these next statements into a loop because we might encoun +ter an error # we can recover from. If so, the 'eval' will catch it and throw + it to 'if ($@)' while ($sqlSuccess == 0) { eval { $dbh->{RaiseError} = 1; $sth = $dbh->prepare($sqlStatement); $sth->execute(); print $fileHandle "rows affected - " . $sth->rows . "\n"; while (my @row=$sth->fetchrow_array()) { if (defined $queryFiles{$query}) { print queryLog "@row\n"; } $rowCount++; } $sqlSuccess = 1; }; if ($@) { print $fileHandle "caught error $@\n"; my $errString = $@; print $fileHandle "here err string is |$errString|\n"; if ($errString =~ m|Table '(.*)' already exists|) { print $fileHandle "got to here\n"; my $sql = "drop table " . $1; my $drop = $dbh->prepare($sql); $drop->execute(); } else { return "Error found - $errString"; } } }
If I invoke my program from the command line, this works fine, that is, if the table I'm trying to overwrite (an Access table) already exists, the 'eval' loop catches it and the table is dropped and the process continues. BUT . . . the user wanted it to be more GUI, so I wrote a Tkx thing, which includes this:
my $Email3; $Email3 = $mw->new_button( -text => "Email3", -command => [\&doTheWork,"Email3"], ); $Email3->g_pack(-padx=>10, -pady=>10,);
When I use the 'Email3' button, the program goes ahead and does a whole bunch of work UNTIL it gets to the case where the table already exists, then it just bombs out and nothing I have tried so far catches the error "table already exists". I'm fresh out of ideas. Anyone know what to do about this? I'm running ActiveState (downloaded and installed this week) on Windows XP Pro, service pack 3.

In reply to eval doesn't work under tkx by nyj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.