my $q = 'INSERT INTO some_table (data) VALUES (?)'; my $sth = $dbh->prepare($q); while(my $data = $csv->get_next_line()) { eval{ $sth->execute($data); } if($@) { next; } # More code here... }