The OP wanted to compare 10 columns at a time with a sliding window, i.e. columns 1 - 10 then 2 - 11 etc. I think your code will give columns 1 - 10 then 11 - 20 etc.

$ perl -E ' > $rowTxt = ( q{0123456789} x 2 ) . q{0123}; > @groups = $rowTxt =~ m{.{1,10}}g; > say for @groups;' 0123456789 0123456789 0123 $

Perhaps a look-ahead would give the sliding window the OP wanted.

$ perl -E ' > $rowTxt = ( q{0123456789} x 2 ) . q{0123}; > @groups = $rowTxt =~ m{(?=(.{10}))}g; > say for @groups;' 0123456789 1234567890 2345678901 3456789012 4567890123 5678901234 6789012345 7890123456 8901234567 9012345678 0123456789 1234567890 2345678901 3456789012 4567890123 $

I'm not sure why the OP is going about the comparison this way. Perhaps s/he wants to pin down exactly where the strings differ. If so, XOR'ing the rows and detecting the position of any ones might be more efficient.

$ perl -E ' > $sa = q{abcdefg}; > $sb = q{abbdegg}; > $df = $sa ^ $sb; > say q{Zero-based counting}; > 1 while $df =~ m{\x01(?{ say pos( $df ) - 1 })}g; > say q{One-based counting as per OP example}; > 1 while $df =~ m{\x01(?{ say pos $df })}g;' Zero-based counting 2 5 One-based counting as per OP example 3 6 $

I hope this is of interest.

Cheers,

JohnGG


In reply to Re^2: Comparison of the row by using window size by johngg
in thread Comparison of the row by using window size by snape

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.