So I guess that the reason you try cloning the database handle is to reuse the connection parameters?
In that case, you can just write a sub that returns a closure which in turn creates a database handle with all the right parameters.
sub get_dbh_factory {
my @config = @_;
return sub {
return DBI->connect(@config);
}
}
sub somewhere_else {
my $dbh_factory = get_dbh_factory( ... );
if(fork == 0) {
my $dbh = $dbh_factory->();
...
} else {
my $dbh = $dbh_factory->();
...
}
}
Code above is sloppy and just a sketch, but the principle behind should work.
|