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... } } #### while ( my $data = ... ) { $sth->execute( $data ) or next; }