use constant MOVEMENT => 3; use constant WINDOWSIZE => 10; my $dna = 'accatgagctgtacgtagcatctgagcgcgcatgactgtgactgacgtaggcagca'; my @windows=(); for (my $pos = 0; $pos <= (length($dna) - WINDOWSIZE); $pos += MOVEMENT) { push(@windows,substr($dna,$pos,WINDOWSIZE)); } print "@windows\n";