in reply to Using a single DBI handle in a script and a module
This way you let the module control the connection and you can quite easily set a connection or use it.sub SomeDBRoutine { my $self = shift; $obj->dbh->WhatEver; } sub dbh { my $self = shift; if ( @_ ) { $connection_string = shift; $self->{dbh} = DBI->Connect($connection_string, "user","pass"); } return $self->{dbh}; }
|
|---|