package DBH; use strict; use DBI; @ISA = qw(Exporter); @EXPORT_OK = qw(&DBHOBJ); my $dbhobject = new(); sub new { my $classname = shift; my $self={}; if ($dbhobject) { $self=$dbhobject } else { $self = bless {}; my $dbh = DBI->connect("DBI:mysql:blah) or die DBI::errstr; $self->{"dbh"} = $dbh; } $self; } sub DBHOBJ { return $dbhobject->{"dbh"}; } sub DESTROY { my $self=shift; if ($dbhobject) { $dbhobject = undef; } } #### use strict; use DBH qw(&DBHOBJ); my $sth = DBHOBJ()->prepare('select blah from table;'); $sth->execute();