@ayo Have you ever tried DBIx::Class? It's a pretty flexible ORM that allows you to construct queries using nothing but hashes and other #perl data structures. If you're looking to dynamically construct SQL queries easily, it's probably a better place to start (even if you don't use it directly you can mine it's source code for ideas)
@splatt9990 I have, but I wasn't impressed. Not sure about the exact reasons because it's been a while, but from what I remember it seemed both over-engineerd, inflexible and a memory hog. What I'm using now is a thin abstraction on top of SQL::Interp, and that kinda works.