The problem with
for (@binds) { undef $binds[$i] unless $binds[$i]; ++$i; }
is that you'll bind NULL in place of zero or blank. If that's what you want, then O.K. If it's not what you want, then you need to make sure that you're carrying around a blank or zero in your data structures where you really undef/NULL. Then you can omit the statement above entirely.