Is that an error you get from Perl, or from your database?
In the latter case, it all depends on the content of the
various variables you are using. I'd strongly suggest you
use placeholders, and if you don't, to interpolate your
variables instead of using a thousand quotes and dots.
Making your code readable is a large step towards finding errors.