my $sql = <<'END'; select the_data from my_table where filter1 = $bind_val_1 and filter2 = $bind_val_2 END # dbh is my database handle, already connected here my $sth = $dbh->prepare($sql); $sth->execute; # This line now completes successfully my $data = $sth->fetchall_arrayref;