cav has asked for the wisdom of the Perl Monks concerning the following question:
LONG:while (<READ>) { $jump ++; if ($jump <= $rows2jump){ $counter2++; next LONG; } $counter2++; #number of lines processed #Lets deal with the sequences head here if ($_ =~ /^>/) { $h_title = "$_"; $h_title =~ s/^>//; #Check if head exists #If head doesnt exist, insert it in the <br>head index + table $sth1->execute($h_title) or <br>print "$DBI::errstr"; #Get last id $h_title_counter = $dbh->selectrow_array("SELECT MAX(i +d) FROM head_index"); next LONG; } #Here we will deal with the actal sequence chop; #To remove the > at the end of the line my $line = "$_"; #Input stuff in mysql for my $x (0 ... (length($line) - ($word_length)-1)) { my $word = substr($line, $x, $word_length); <br> #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 ($dbh->selectrow_array("SELECT 1 FROM e_match_ +word WHERE word = ?", undef, $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); $status = "Searching for exact patterns.. processing line +$counter2 of $counter"; $mw->update(); $mw->update; exit if ($stop); } close (READ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Memory Overflow
by tachyon (Chancellor) on Jan 05, 2004 at 23:50 UTC | |
by Anonymous Monk on Jan 06, 2004 at 07:36 UTC | |
by tachyon (Chancellor) on Jan 06, 2004 at 10:01 UTC | |
|
Re: Memory Overflow
by edan (Curate) on Jan 06, 2004 at 07:19 UTC | |
|
Re: Memory Overflow
by Joost (Canon) on Jan 06, 2004 at 00:02 UTC |