in reply to Re: Handling a Database Error
in thread Handling a Database Error

You'll need to set local $dbh->{RaiseError} = 1; above your while-loop for that to guarantee working in all situations. And, since you're using local, I'd recommend a bare-block.
my $q = 'INSERT INTO some_table (data) VALUES (?)'; my $sth = $dbh->prepare($q); { local $dbh->{RaiseError} = 1; while(my $data = $csv->get_next_line()) { eval{ $sth->execute($data); } if($@) { next; } # More code here... } }

Of course, with RaiseError set to false, you can also do the more readable:

while ( my $data = ... ) { $sth->execute( $data ) or next; }
It's up to you and the style you choose to work with. Either way, be consistent. (You wrap your execute(), but not your prepare() ... tsktsk!)

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?