Pathologically Eclectic Rubbish Lister | |
PerlMonks |
package DBconnector; my $singleton; sub new { my $class = shift; $singleton ||= bless {}, $class; } sub connect { my $self = shift; if (exists $self->{dbh}) { $self->{dbh}; } else { my $connection = "dbi:mysql:host=$self->{host} \ dbname=$self->{name}"; $self->{dbh} = DBI->connect($connection, \ $self->{user},$self->{password}); } }
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Perl Singletons
by merlyn (Sage) on Jul 19, 2002 at 19:52 UTC | |
by Aristotle (Chancellor) on Jul 19, 2002 at 20:44 UTC | |
Re: Perl Singletons
by gav^ (Curate) on Jul 19, 2002 at 23:16 UTC | |
Re: Perl Singletons
by atcroft (Abbot) on Jul 23, 2002 at 17:16 UTC |