my $dbh = DBI->connect( "dbi:SQLite:dbname=SSBHLD2.db", "", "", { RaiseError => 1 }, ) or die $DBI::errstr; $dbh->do("CREATE TABLE IF NOT EXISTS HLDdata(Data TEXT)"); while(){ $line = $_; my $sth = $dbh->prepare( "select count(*) from HLDdata where Data = '$line'"); $sth->execute(); my ($data) = $sth->fetchrow(); print "$data \n"; if ($data ne 0){ print "record exist not adding\n"; &Logit("record exist not adding"); }else{ $dbh->do("INSERT INTO HLDdata(Data) VALUES ('$line')"); $line =~s/\|/\t/g; print "$line\n"; print OUT "$line"; } } close(IN); close(OUT);