# we don't need this in the loop as we know when we increment (unless forking) # also syntax IS WRONG in original - need array context on LHS to get val # otherwise you are always going to get the val 1 ($h_title_counter) = $dbh->selectrow_array("SELECT MAX(id) FROM head_index"); # this should be a sth with bind not $dbh->selectrow_array every time my $sthX = $dbh->prepare("SELECT 1 FROM e_match_word WHERE word = ?"); LONG: while () { next if $. <= $rows2jump; $counter2++; #number of lines processed #Lets deal with the sequences head here, marked by > so this will # only exec if we have that marker if ( s/^>// ) { $sth1->execute($_) or print "$DBI::errstr"; $h_title_counter++; next LONG; } #Here we will deal with the actal sequence chop; #To remove the > at the end of the line #Input stuff in mysql for my $x (0 ... (length($line) - ($word_length)-1)) { my $word = substr($_, $x, $word_length); #Now we have it with a big cache, hope to speed things up if ($most_used_words{$word}) { #UPDATE e_match_word set counter = counter+1 WHERE word = ? $sth3->execute($word) or print "$DBI::errstr"; #print "cached result\n"; } elsif ( $sthX->execute($word)) { #UPDATE e_match_word set counter = counter+1 WHERE word = ? $sth3->execute($word) or print "$DBI::errstr"; #print "not cached result\n"; } else { #INSERT INTO e_match_word VALUES (?,?) $sth2->execute($word, 1) or print "$DBI::errstr"; $wordcounter++; #print "new word\n"; } #INSERT INTO e_match_info values (?,?,?) $sth4->execute($word, $h_title_counter, $x) or print "$DBI::errstr"; } #$percent_done = int(($counter2/$counter) * 100); # you are setting status but never use it...... #$status = "Searching for exact patterns.. processing line $counter2 of $counter"; $mw->update(); # $mw->update; <--- duplicate # exit if ($stop); <--- never set in loop } close (READ);