Somewhat tangential to your question, but have you considered looking at
SQL::Abstract for building your SQL statement? You might be able to devise a direct mapping between the input from your form and the
SQL::Abstract-data structures, so the
WHERE-clause would literally build itself.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law