|Perl: the Markov chain saw|
Re: storing database handle object in a variableby kyle (Abbot)
|on Dec 09, 2009 at 15:25 UTC||Need Help??|
You may be trying to do this:
If that's your goal, you're sunk. The $dbh is not a mere piece of data like an account number or the text of the Camel book that you can write and read back later. Instead, it is an object holding an open socket to a database. The network connection that has been opened can't be serialized for later.
If you want to use the same connection to a database in two places concurrently, you're still sunk. Only one process can use a connection at a time. To get that behavior, you'd have to have a process that connects to the database and then acts as a traffic cop for other processes that want to use the connection. In that case, you might as well have the other processes connect directly.
If what you want to do is open a connection to a database and then start another program that uses that connection, you can sort of do that. Have a look at DBI, fork, and clone. for a way to go.
But really, why do you want to do this? What is the problem you face that causes you to seek this solution?