title: Remove repeated lines in a file based on pattern
body: <p>I've tried to find a good way to carry out this, but unfortunatly I didn't find one. </p>
  
  <p>I'm working with files with this format:</p>
  
  <blockquote>
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22491.xml;spectrum=1074 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=2950 true    </p>
    
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=1876 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=3479 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=3785 true</p>
    
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22493.xml;spectrum=473  true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22493.xml;spectrum=473  true</p>
  </blockquote>
  
  <p>As you can see, every SPEC line is different, except the last one, where number of the string spectrum is repeated. 
  What I'd like to do is take every chunk of information between the pattern <code>=Cluster=</code> and check if there are lines with spectrum value repeated. In case there are several lines repeated, removes all except one.</p>
  
  <p>The output file should be like this: </p>
  
  <blockquote>
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22491.xml;spectrum=1074 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=2950 true    </p>
    
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=1876 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=3479 true<br>
    SPEC  PRD000681;PRIDE_Exp_Complete_Ac_22498.xml;spectrum=3785 true</p>
    
    <p>=Cluster=<br>
    SPEC    PRD000681;PRIDE_Exp_Complete_Ac_22493.xml;spectrum=473  true    </p>
  </blockquote>
  
  <p>I'm using this to split the file using the pattern but I don't know how to check if there are spectrum repeated.</p>
  
  <pre><code>#!/usr/bin/perl
  
  undef $/;
  $_ = &lt;&gt;;
  $n = 0;
  
  for $match (split(/(?==Cluster=)/)) {
        open(O, '&gt;temp' . ++$n);
        print O $match;
        close(O);
  }
  </code></pre>
  
  <p>PD: I used Perl because it's easier for me, but I understand python as well. </p>