perlquestion kyle <p>Venerable monks, <p>I'm looking for a module that will cache a database handle for me and correctly handle when the program [doc://fork]s. I know [mod://DBIx::Class] does this, but I don't need or want the ache of defining a schema and such, just the handle. <readmore> <p>I have a program that uses a database. In it, I have a simple function to get a connection to the database. <c> sub dbh { my ($u,$p) = ('user',':)'); my $dbh = DBI->connect( "", $u, $p, { RaiseError => 1 }, ); $dbh->do( $initial_stuff ); $L->debug( "made new database connection $dbh" ); return $dbh; } </c> <p>That works fine. It would be easy enough to write something that caches that using a state variable. <c> sub dbh { state $dbh; if ( ! defined $dbh ) { # blah blah bah } return $dbh; } </c> <p>That way I don't open up a new connection every time I need to talk to the database. Unfortunately, that will get tripped up when I [doc://fork]. </readmore> <p>I know about [id://594175] I know how to write the code to get around this. What I want is a module that's already done it for me. Does it exist?