Further to the hint in haukex's post:   The bitwise-xor of equal length strings (update: assumed to be ASCII strings; see sundialsvc4's point here++) is a neat differencing trick. Here's an example that extracts zero-based offsets of differing characters:

c:\@Work\Perl\monks>perl -wMstrict -le "my ($x, $y, $z) = qw(TTTATTT TTTTTTT TBTTTTT); ;; for my $ar ([ $x, $y ], [ $x, $z ], [ $y, $z ], ) { my ($p, $q) = @$ar; my $d = $p ^ $q; my @offsets; push @offsets, $+[0]-1 while $d =~ m{ \G \x00* [^\x00] }xmsg; print $p; print $q; if (@offsets) { printf qq{diff(s) at offset(s) %s \n}, join q{, }, @offsets; } else { print qq{no diffs \n}; } } " TTTATTT TTTTTTT diff(s) at offset(s) 3 TTTATTT TBTTTTT diff(s) at offset(s) 1, 3 TTTTTTT TBTTTTT diff(s) at offset(s) 1
BTW: I, too, find your OP a bit vague.

Update: Arrrgh! Use  m{ [^\x00] }xmsg instead of  m{ \G \x00* [^\x00] }xmsg (simpler == better).
Double Arrrgh! Even simpler: Instead of
    push @offsets, $+[0]-1 while $d =~ m{ [^\x00] }xmsg;
use
    push @offsets, $-[0] while $d =~ m{ [^\x00] }xmsg;
(See perlvar for  @+ and  @- regex special variables.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: compare initial by AnomalousMonk
in thread compare initial by dideod.yang

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.