http://www.perlmonks.org?node_id=971290


in reply to How can I get the correct results for substrings 2 and 3 in a do-until loop?

How can I correct the code in line 10 for while loop while (my $fm= substr ($DNA1,0,4)) {

If I'm understanding you correctly, you want to update the offset in that substr:

my $offs = 0; while (my $fm= substr($DNA1, $offs, 4)) { $offs += 4; ... }

or

for (my $offs=0; my $fm=substr($DNA1, $offs, 4); $offs+=4 ) { ... }

That would give you the 3 substrings "GGCT", "CTGC" and "GCGG".

  • Comment on Re: Why am I getting the result only from 1st substring and not from substring 2 and 3 in using the do-until loop with while loop inside it?
  • Select or Download Code