title: Fastest Way To Find Mismatch Positions Between Two Strings of the Same Length
body: <p>I have a millions of pairs of string of same length which I want to compare and find 
  the position where it has mismatches.</p>
  
  <p>For example for each <code>$str1</code> and <code>$str2</code> we want to find mismatch
  position with <code>$str_source</code>:</p>
  
  <pre><code>$str_source = "ATTCCGGG";
  
  $str1       = "ATTGCGGG"; # 1 mismatch with Str1 at position 3 (0-based)
  $str2       = "ATACCGGC"; # 2 mismatches with source at position  2 and 7
  </code></pre>
  
  <p>Is there a fast way to do it. Currently I have the C style method which I loop
  every position in both strings using 'substr' function. But this approach is horribly slow.</p>
  
  <pre><code>my @mism_pos;
  for $i (0 .. length($str_source)) {
     $source_base = substr($str_source,$i,1);
     $str_base    = substr($str2,$i,$1);
  
    if ($source_base ne $str_base) {
       push @mism_pos,$i;
    }
  
  }
  </code></pre>