package DBConnection; my $dbm; #==========# sub new { #==========# my($class, $name) = @_; my $self = { name => $name }; bless($self, $class); return $self; } #============# sub instance #============# { my ($class)= @_; if(not defined $dbm) { $dbm = new DBConnection(); } return $dbm; } #==========================# sub getSingleConnection #==========================# { my ($self) = @_; unless($dbm->{dbh}) { $dbm->{dbh} = $self->getConnection(); } return $dbm->{dbh}; } #==================# sub getConnection #==================# { my ($self) = @_; my $dbh; eval { $dbh = DBI->connect('dbi:Oracle:host=dbserver;sid=db_sid;port=1521','user','passwrd'); or return undef; }; warn $@ if $@; return undef if $@; return $dbh; }