in reply to connection to database interfering with $?

Read description of $? carefully. There it states that if SIGCHLD is set, then $? shall be incorrect. Check the following code

system('true'); print "\$? is $?\n"; $SIG{CHLD} = 'IGNORE'; system('true'); print "\$? is $?\n";

From this follows, that most likely your DBI call has set the $SIG{CHLD} and didn't clear it.