# We put these next statements into a loop because we might encounter 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"; } } }