title: how to limit the found matches on perl using regex?
body: <p>I come to ask for your aid after a lot of research on this matter:</p>
  
  <p>I'm trying to limit the repetition of the substitutions that a Perl regex does on a big text. 
  I've searched in Google and found that the format is {2,3}  (min, max) however this seems to be for a different way that the syntax I'm using.</p>
  
  <pre><code>$replaced=~s/$var/$var2/g; # replaces all ocurrences
  $replaced=~s/$var/$var2/;  # replaces only first one
  </code></pre>
  
  <p>my non optimal solution:</p>
  
  <pre><code>for($i=0; $i&lt;8; $i++){
  
      $replaced=~s/$var/$var2/;
  }
  </code></pre>
  
  <p>What I have tried:</p>
  
  <pre><code>$replaced=~s/$var/$var2/{8};
  $replaced=~s/$var/$var2{8}/;
  </code></pre>
  
  <p>Any help will be appreciated!</p>
  
  <p>edit: 
  OK so pretty much there has to be a loop involved huh.. isn't that weird that there is not a built in parameter to limit it??</p>