in reply to substr help
Or use a capture within a lookahead:## capture 10 chars (with advancing), then move back 7: while ( $dna =~ /(.{10})/g ) { print "current window = $1\n"; pos $dna -= 7; }
For maintenance/readability reasons, you may be better off using a for loop and substr. I don't know, though; I kinda like the lookahead solution... it's cute.## capture next 10 chars without advancing, then advance by 3: while ( $dna =~ /(?= (.{10}) ) .{3}/gx ) { print "current window: $1\n"; }
blokhead
|
|---|