in reply to Print subroutine problem

The simple solution is to change the anonymous subs to look like this:
sub { print "Active_Conn: ".query_database($querys{activeconn})." " }
And add a print "\n" at the end before exiting. I suggest refactoring it once you get it working.