> is there a way that I can see which of the 10-mers are consecutive and "paste" them into one larger match?

It's not so easy. You can't paste them together, as that might increase the number of mismatches over the threshold.

But you can change the algorithm totally if you want to find the longest matches. Just move the shorter string alongside the longer one, and then for each position try to find the longest match starting there.

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my $stretch = 10; my $mismatches = 1; substr $reference_str, 0, 0, 'x' x (length($small_str) - 1); $reference_str .= 'x' x (length($small_str) - 1); for my $start_pos (0 .. length($reference_str) - length($small_str)) { my $substr = substr $reference_str, $start_pos, length($small_str) +; my ($from, $diffs) = (0, 0); for my $inner_pos (0 .. length($small_str) ) { ++$diffs if substr($substr, $inner_pos, 1) ne substr $small_str, $inner_pos, 1; if ($diffs > $mismatches || $inner_pos == length($small_str) ) + { say join "\n\t", $start_pos + $from + 1 - length $small_str, substr($small_str, $from, $inner_pos - $from), substr($reference_str, $from + $start_pos, $inner_pos +- $from) if $inner_pos - $from >= $stretch; ++$from until (substr $small_str, $from, 1) ne substr($sub +str, $from, 1) || $from > $inner_pos; ++$from; --$diffs; } } }

> was the problem I asked for a question of finding the longest possible match with one mismatch allowed?

Basically, yes.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

In reply to Re^5: How do you match a stretch of at least N characters by choroba
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.