package External;
sub dbh { $External::dbh ||= DBI->connect( 'DBI:mysql:test','root','' ) } #dbh
####
package Foo;
sub new {
my $dbh = External->dbh; # how we get the $dbh is not the question here
my $driver = $dbh->SOMETHING; # now set to 'mysql', but what is "SOMETHING" ?
bless {},__PACKAGE__.'::'.$driver;
}
sub general { same for all database drivers }
##
##
package Foo::mysql;
@ISA = qw(Foo);
sub specific { stuff specific to MySQL }
##
##
$dbh->{Driver}{Name}; # gives "mysql"
$dbh->get_info( 17 ); # gives "MySQL"