i don't see any way to do it besides eating letters from the back, then starting over from the front.
here is one way, though index() would surely be faster than m// here.
my $sequence = "GAATGTTTTAGCAATCTCTTTCTGTCATGAATCCATGGCAGTGACCATACTAAT
+GGTGACTGCCATTGATGGAGGGAGACACA";
my $find = "CTGGATAAGAATGTTTTAGCAATCTCTT";
my $found;
MATCH: {
my $tail = $find;
while ( length($tail) > 2 and not $found ) {
($found) = $sequence =~ /($tail)/ # find match
or substr( $tail, 0, 1, ''); # or eat first letter
}
last MATCH if $found;
my $head = $find;
## can chop first since exact match already failed
while ( chop $head and length($head) > 2 and not $found ) {
($found) = $sequence =~ /($head)/;
}
}
print "found? $found\n";
updated: to provide better(?) var names