in reply to why is substr behaving odd?

substr can take a third parameter indicating length, not ending position. In other words:

my $sub = substr ($seq, $end, 1000);

I hope this helps you with your problem.