title: Variable inside grep in Perl
body: <p>I have to search for a pattern inside a variable in Perl.
  The pattern also needs to be inside a variable.
  Here is what I have:</p>
  
  <pre><code>opendir(DIR,"reports/");
  $poolname = $poolname."_";
  @FILES= grep {/^$poolname\.[0-9]*.csv/} readdir(DIR);
  @sorted= reverse sort @FILES;
  </code></pre>
  
  <p>The pattern I want to match is poolname_[0-9]*
  (I'm trying to get the latest report for a pool here. [0-9]* is the unix timestamp of the file)</p>
  
  <p>But the above regex is not working as expected. 
  $sorted[0] doesn't have the required filename.
  May I know what is wrong with the above code?</p>