in reply to substr help
Also, the third argument to substr is the number of characters you want; using 0 will always return an empty string. And in your loop, you're starting at 10 and stopping when the position is greater than the number of elements in @dna, but there's only one element in that list, so the loop never executes.
I think something closer to what you mean is:
use constant MOVEMENT => 3; use constant WINDOWSIZE => 10; my $dna = 'accatgagctgtacgtagcatctgagcgcgcatgactgtgactgacgtaggcagca'; my @windows=(); for (my $pos = 0; $pos <= (length($dna) - WINDOWSIZE); $pos += MOVEMEN +T) { push(@windows,substr($dna,$pos,WINDOWSIZE)); } print "@windows\n";
|
|---|