> 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.

- Perrin

Reply via email to