in reply to pass $dbh object to new program
A $dbh is a database handle - a specific connection between a script and a database. You can not pass it from one script to another without a general persistence scheme like mod_perl. Pass the DSN instead. In other words if you get your $dbh in program #1 with $dbh=DBI->connect('dbi:Pg:database=foo'), pass "dbi:Pg:database=foo" to program #2 and reconnect in program #2.