in reply to How do you match a stretch of at least N characters

One way you could to it is use the ^ operator. When applied on strings, it will output 0 wherever the two are equal, and something else wherever they are different. That way searching for a series of identical characters becomes searching for a series of 0.

for my $position (0..(length($reference_str)-length($small_str))) { my $processed_str = $small_str ^ substr($reference_str, $position, l +ength($small_str)); next unless $processed_str =~ m<( \0{9} | \0{1} . \0{8,} | \0{2} . \0{7,} | \0{3} . \0{6,} | \0{4} . \0{5,} | \0{5} . \0{4,} | \0{6} . \0{3,} | \0{7} . \0{2,} | \0{8} . \0{1,} )>xms; print("Match found! ", substr($reference_str, $position+pos($proces +sed_str),length($1))) and last; }
Untested :)