Gunther Birznieks wrote:
> 
> At 07:16 PM 8/1/2001 -0400, Perrin Harkins wrote:
> > > I have a CGI application where I do:
> > >
> > > require 'db.pl';
> > >
> > > where db.pl defines some functions and variables related to connecting to
> > > the database, and then executes C<$dbh = DBI->connect(...)>.
> >
> ><snip>
> >
> > > I can get around this by changing C<require> to C<do>, but is that the
> > > "correct" way of doing things?
> >
> >No.  Put the connect stuff in a subroutine and call it from your
> >application.  Things in the main section of a required file are only
> >supposed to run once.
> 
> I am not sure, but I don't think connect() is only supposed to run once
> especially with Apache::DBI?

Right, and at the moment he has it in the main section, so it's only
running once.  He should move it to a sub and call it from his
application so it gets run every time.

Reply via email to