$sth->prepare( "INSERT INTO Blah ( a, b, c ) VALUES ( ?, ?, ? )" ); tie *TSV, 'File::ReadBackwards', $filename; while( ) { my @insert = processRow( $_ ); $sth->execute( @insert ); truncate $filename, tell TSV; } close TSV; unlink $filename unless $errors;