title: Calling Perl script from PHP and passing in variables, while also using variablized perl script name
body: <p>I normally call perl scripts from PHP as below and pass in variables this way, and it works fine, however now I am building a component for re-use where I want to also variablize the perl script name that I am passing in and this is giving me some headaches, so I am wondering if anyone can point out a better way to do this as my way isn't working.. thanks..</p>
  
  <p>the way that works without variablized perl filename:</p>
  
  <pre><code>$file = "/var/www/other_scripts/perl/apps/perlscript.pl $var1 $var2 $var3 $var4";
  ob_start();
  passthru($file);
  $perlreturn = ob_get_contents();
  ob_end_clean();
  </code></pre>
  
  <p>My attempt to variablize the perl filename that doesn't seem to be working for me, you can see in the above how it is including even the $var(s) in the initial " ", which I find odd but this seems to be the only way that it works and I wasn't sure how to even replicate this with a variablized perl filename:</p>
  
  <pre><code>$perlscript_file = "/var/www/other_scripts/perl/apps/" . $perlscript .".pl";
  
  $file = $perlscript_file . $var1 . $var2  .$var3 . $var4;
  ob_start();
  passthru($file);
  $perlreturn = ob_get_contents();
  ob_end_clean();
  </code></pre>