Since you're opening a file anyway, you might want to consider using the seek and read methods on your filehandle. This will allow you to position the read pointer anywhere you like within the file and read in exactly the number of bytes you require. Also, you will not need to read the entire file into memory before doing the string manipulation.
Update: The above suggestion would still work, but you would need to take into account the formatted nature of your input file. To use the seek method correctly, you would need to take into account the spaces between segments and the leading numbers prefixing each string (and likely the newline which terminates each string.) Using seek would still work, but depending on the format of the full input file, it might not be feasible.
Update II: (Thinking some more...) I have a question regarding the input file and the offset. Is the offset from the textual beginning of the file, or from the beginning of the DNA sequence? It would appear that it's from the beginning of the DNA sequence, but I'm not going to assume here.
In reply to Re: substr is behaving differently with small vs large strings
by Belgarion
in thread substr is behaving differently with small vs large strings
by wadunn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |