title: Is there a way to "allow" a perl RegEx to ignore 1 character at a time when trying to match?
body: <p>Basically, I have several files, each one with several lines of text, and I'm interested in finding a specific sequence of 7 letters and count how many time they appear per file using some basic regular expressions on Perl(v5.24.1). </p>
  
  <p>So far no problem, but the "tricky" part is that if one of those seven letters doesn't match my pattern, I would like to count it as well (as long as it's just one).</p>
  
  <p>Patterns I'm looking for: 
  <code>'CCCAGGT', 'CCCAGTT', 'CCCAGCT', and 'CCCAGAT'.</code></p>
  
  <p>Examples of non-matching text that I would like to count:</p>
  
  <pre><code>line1 - AGGCTCAGGAG'CCCATGT'GGGCGGACCCAT --&gt; Count as 'CCCAGGT'
  line2 - CGGCTCAGGAG'CCCGGGT'GGGCGGTCCCAT --&gt; Count as 'CCCAGGT'
  </code></pre>
  
  <p>I'm including a piece code (at the bottom) to further explain what I'm searching and what I've thought so far, but it has to be a better way of doing this.</p>
  
  <p>So, do you know if it's possible to "tell" Perl that I can tolerate 1 mismatch in the sequence when using the <code>=~ m/</code> operator? OR another function to use?</p>
  
  <p>Thanks a lot for your help!</p>
  
  <pre class="lang-perl prettyprint-override"><code>  if ($elements[0] =~ m/CCCAGGT/){
      $mutg = $mutg + $elements[1];
    }
    elsif ($elements[0] =~ m/CCCAGTT/){
      $mutt = $mutt + $elements[1];
    }
    elsif ($elements[0] =~ m/CCCAGAT/){
      $muta = $muta + $elements[1];
    }
    elsif ($elements[0] =~ m/CCCAGCT/){
      $mutc = $mutc + $elements[1];
    }
    else {
      if ($elements[0] =~ m/.CCAGGT/){
        $mutg = $mutg + $elements[1];
      }
      elsif ($elements[0] =~ m/.CCAGTT/){
      $mutt = $mutt + $elements[1];
      }
      elsif ($elements[0] =~ m/.CCAGAT/){
        $muta = $muta + $elements[1];
      }
      elsif ($elements[0] =~ m/.CCAGCT/){
        $mutc = $mutc + $elements[1];
      }
      else {
        [[AGAIN BUT WITH THE "." IN THE SECOND POSITION AND SO ON]]
      }                         
    }
  </code></pre>