title: How can I expand variables in a Perl string?
body: <p>I am trying to expand the string <code>$searchCriteria</code> in the if condition. Any clues?</p>
  
  <pre><code>use strict;
  
  my $argNum;
  my $searchCriteria = "";
  foreach $argNum (0 .. $#ARGV) {
      $searchCriteria = $searchCriteria . "(\$_ =~ \/" . $ARGV[$argNum] . "\/i) &amp;&amp; ";
  }
  $searchCriteria =~ s/&amp;&amp; $//; 
  #print $searchCriteria;
  
  open IP, "&lt;vm.txt" or die $!;
  
  my @fileContents = &lt;IP&gt;;
  foreach (@fileContents) {
      if (${$searchCriteria}) {
          print $_;
      }
  }
  </code></pre>