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 :)


In reply to Re: How do you match a stretch of at least N characters by Eily
in thread How do you match a stretch of at least N characters by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.