Unless I'm mistaken, all you have to do is put each distinct connection in a distinct variable. Put a connection to the Foo database in a $foo_db variable, and a connection to the Bar database in a $bar_db variable, and then use the appropriate variable to communicate with the appropriate database. Really fancy would be $db['Foo'] and $db['Bar'].
I am certain that you don't have to call the variable "$dbh".