## capture 10 chars (with advancing), then move back 7: while ( $dna =~ /(.{10})/g ) { print "current window = $1\n"; pos $dna -= 7; } #### ## capture next 10 chars without advancing, then advance by 3: while ( $dna =~ /(?= (.{10}) ) .{3}/gx ) { print "current window: $1\n"; }