http://qs321.pair.com?node_id=1214491


in reply to Re^2: RFC: Is the Bible encoded in DNA?
in thread RFC: Is the Bible encoded in DNA?

Nobody has spotted the obvious, that the code for reading the file is painfully slow.

A significant improvement would be:

while (read($fh, my $char, 1) && $eof) { if ($char =~ m/[ACGT]/ ) { $i++; if ($i >= $start_genome && $i < $end_genome) { push (@genome, $char); } elsif ($i > $end_genome) { $eof = 0; # do the searching here, instead of outside the loop! } } }

Replies are listed 'Best First'.
Re^4: RFC: Is the Bible encoded in DNA?
by wstryder (Novice) on May 14, 2018 at 20:56 UTC
    That's now fixed and the algorithm doesn't go back to the beginning of the file every time a chunk is read. Silly me.