title: How can I escape meta-characters when I interpolate a variable in Perl's match operator?
body: <p>Suppose I have a file containing lines I'm trying to match against:</p>
  
  <pre><code>foo
  quux
  bar
  </code></pre>
  
  <p>In my code, I have another array:</p>
  
  <pre><code>foo
  baz
  quux
  </code></pre>
  
  <p>Let's say we iterate through the file, calling each element <code>$word</code>, and the internal list we are checking against, <code>@arr</code>.</p>
  
  <pre><code>if( grep {$_ =~ m/^$word$/i} @arr)
  </code></pre>
  
  <p>This works correctly, but in the somewhat possible case where we have an test case of <code>fo.</code> in the file, the <code>.</code> operates as a wildcard operator in the regex, and <code>fo.</code> then matches <code>foo</code>, which is not acceptable.</p>
  
  <p>This is of course because Perl is interpolating the variable into a regex. </p>
  
  <p>The question: </p>
  
  <p><em>How do I force Perl to use the variable literally?</em></p>