title: Perl pattern match variable question
body: <p>I'm trying to open a file, match a particular line, and then wrap HTML tags around that line. Seems terribly simple but apparently I'm missing something and don't understand the Perl matched pattern variables correctly.</p>
  
  <p>I'm matching the line with this:</p>
  
  <pre><code>$line =~ m/(Number of items:.*)/i;
  </code></pre>
  
  <p>Which puts the entire line into $1. I try to then print out my new line like this:</p>
  
  <pre><code>print "&lt;p&gt;" . $1 . "&lt;\/p&gt;;
  </code></pre>
  
  <p>I expect it to print this:</p>
  
  <pre><code>&lt;p&gt;Number of items: 22&lt;/p&gt;
  </code></pre>
  
  <p>However, I'm actually getting this:</p>
  
  <pre><code>&lt;/p&gt;umber of items: 22
  </code></pre>
  
  <p>I've tried all kinds of variations - printing each bit on a separate line, setting $1 to a new variable, using $+ and $&amp;, etc. and I always get the same result.</p>
  
  <p>What am I missing? </p>