A DBI handle contains a bit (or a lot, depending on the particular DBD backend it's using) of context which may not even be valid in another process' context. Passing it (or in your case a stringified representation of it) to another process on the command line isn't going to work (depending on the DBD and what backend library it uses you might could do some wicked file descriptor voodoo in the child, but that's going to be highly DBD and database dependent if it's even possible). If it truly must be a separate process then you're going to have to reconnect in the child to the same database (in which case you could pass the DSN and credentials to it). Or rework your design so that the other code is a module or something you can run via do instead of spawning a new process.
| [reply] [d/l] |
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. | [reply] |
| [reply] |