--- trunk2/index_DBI_cache.pm 2004/06/10 19:22:40 337 +++ trunk2/lib/WebPac/Index.pm 2004/06/13 20:20:29 348 @@ -6,12 +6,13 @@ # library). But, that functionality is not used anyway... # -package index_DBI; +package WebPac::Index; use strict qw(vars); use vars qw($Count); use HTML::Entities; use URI::Escape; use locale; +use Carp; use DBI; @@ -36,20 +37,18 @@ sub new { my $class = shift; - my $self = {}; + my $self = {@_}; bless($self, $class); - my $dbd = shift || die "need dbi_dbd= in [global] section of configuration file"; - my $dsn = shift || die "need dbi_dsn= in [global] section of configuration file"; - my $user = shift || die "need dbi_user= in [global] section of configuration file"; - my $passwd = shift || die "need dbi_passwd= in [global] section of configuration file"; + croak "need dbd" if (! $self->{dbd}); + croak "need dsn" if (! $self->{dsn}); + croak "need user" if (! $self->{user}); + croak "need passwd" if (! $self->{passwd}); - $self->{dbd} = $dbd; - - $self->{dbh} = DBI->connect("DBI:$dbd:$dsn",$user,$passwd) || die $DBI::errstr; + $self->{dbh} = DBI->connect("DBI:$self->{dbd}:$self->{dsn}",$self->{user},$self->{passwd}) || die $DBI::errstr; $Count++; - $self->bench("connected to $dbd as $user"); + $self->bench("connected to $self->{dbd} as $self->{user}"); # force SQLite to support binary 0 in data (which shouldn't # happend, but it did to me)