in reply to substr is behaving differently with small vs large strings

Your code (and substr) works fine. I just generated a 2.6 MB test file, put START and END at the appropriate places and the results are exactly what you want.

That leaves a couple fo possibilities.

  1. Either your method of checking is wrong.
  2. The large file is not quite in the format your expecting.

BTW. You could replace your editcontig() sub with

my $contigfile = "$contig.txt"; open(CONTIG, $contigfile) or die (">Could not open $contigfile!\n$!"); my $goodseq = <CONTIG>; $goodseq =~ tr[0-9\n ][]d; #clear giant variable to free some memory???? # $rawseq = '';

This will reduce the memory required by your program from 35 MB to around 6MB.

It will also speed it up slightly, but if that offends you, you can always add a sleep 10; :)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon