in reply to
Mixing Perl and SQL
This does not strictly answer your question but it works well for us and you might find it useful. The ONLY SQL we have in our application is:
begin synonym.proc_name(?, ? ....); end;
begin ? := synonym.func_name(?, ?, ...); end;
All the SQL is in procedures and functions in the database - including those that simply return a result-set. This allows us to keep all the logic in the database. Of course you can only do this if your DBD and database supports procedures and the returning of reference cursors which DBD::Oracle and Oracle does.