After counting residues and I applied if condition. I could able to print 30nts stretches only. I am not able to print min. of 15nt stretches and maximum of continuous stretches of any length. For that I tried with join and push command. It prints all or joining the same seq. Could you please guide me to solve this problem.

Most of us are not biologists. We have no idea what your are asking. You will receive far more answers if you rephrase your question avoiding the jargon of biology. (When this is not possible, define the term in a way that we can understand) It would also be helpful if you provide several small samples of data and the output you expect from each.

I can suggest several improvements to the code you have shown us:

Avoid c-style for loops.

A match (without /g) in scalar context returns the number of matches See post #5

Your data revealed that my counting was not correct. The match operator does not do exactly what I thought. With that corrected, I can duplicate your expected output by setting $window = 28 and $step = 1. (It also finds several other matches.) I realize that this is just a shorter version of what you already had last week. I still do not understand your original question.

Based on your new comments, I suspect that you should be testing $Gper rather than $AGper.