use SQL::Interpolate qw(:all); my($sql, @bind) = sql_interp q[SELECT * FROM mytable WHERE ], {'time' => $time, 'date' => $date}; # Result: # $sql = "SELECT * from mytable where time=? and date=?" # @bind = ($time, $date); my $sth = $dbh->prepare($sql); $sth->execute(@bind);