title: how to pass in sql query input file to a perl dbi sub routine
body: <p>I like to create a generic perl script that will input sql query from a separate file and use it with perl dbi (subroutine), rather than hardcoding the statement. Can someone show me an example how to do this? </p>
  
  <p>For example I have this in a sub routine:</p>
  
  <pre><code>sub get_val
  {
    my $sth = $dbh-&gt;prepare(q{SELECT count(*) AS COUNT FROM TEST1) ||
        die ("Can't connect: ".$DBI::errstr."\n");         
    $sth-&gt;execute;
    my $row = $sth-&gt;fetchrow_hashref;
    $sth-&gt;finish;
    return $row-&gt;{COUNT};
  }
  </code></pre>