title: Filter strings on word/phrase : Perl
body: <p>I am new at perl and I am looking for some assistance on basically filtering a list of keywords. In short this is to a hash of strings against the same hash of words/phrases. This is to get the lowest common denominator and clean the list up. </p>
  
  <p>For example say the list included the following:</p>
  
  <pre><code>bat
  bat boy
  bat-boy
  bat&amp;boy
  bat:boy
  bat's
  bat-boy's
  batman &amp; bat boy
  </code></pre>
  
  <p>It should only match to the following:</p>
  
  <pre><code>bat boy            (because of bat)
  batman &amp; bat boy   (because of bat)
  </code></pre>
  
  <p>Regex is obviously the way to go, but I am stuck with the following as I can't use /b (word boundary match) as some of the words contain non word characters -,', &amp;,:, etc.</p>
  
  <p>What would be the best way to write the regex? I am checking $keyx against $keyz</p>
  
  <p>Here is the regex:</p>
  
  <pre><code>if $keyx=~m/\Q$keyz\E/
  </code></pre>
  
  <p>Any help would be appreciated</p>