title: How do I replace a token with increasing numbers in Perl?
body: <p>I want to replace a token in a text file with a number. The token is "<code>&lt;count&gt;</code>" and I want it to be replaced with the number of counts so far. For example:</p>
  
  <pre><code>This &lt;count&gt; is a &lt;count&gt; count.
  The &lt;count&gt; count increases &lt;count&gt;&lt;count&gt;&lt;count&gt;.
  &lt;count&gt;&lt;count&gt;&lt;count&gt;&lt;count&gt;&lt;count&gt;&lt;count&gt;
  </code></pre>
  
  <p>becomes:</p>
  
  <pre><code>This 1 is a 2 count.
  The 3 count increases 456.
  789101112
  </code></pre>
  
  <p>I'm not really sure how to do this, maybe with some loop?</p>
  
  <pre><code>my $text = (the input from file, already taken care of in my script);
  my $count = 1;
  while( regex not found? )
  {
      $text =~ s/&lt;count&gt;/($count);
      $count ++;
  }
  </code></pre>