use strict;

Timothy S. Nelson wayland at
Mon Nov 10 05:20:27 CST 2003

On Mon, 10 Nov 2003, andrew at work wrote:

> All, I have been trying to write some nice perl code, which has some
> reusable library subroutines in a ./lib dir.
> It involves opening and closing a database connection and updating some
> info. I have not worked with databases before so maybe there is a better way
> to do this.
> background.
> In order to avoid opening and closing the DB connection to often I have let
> the parent routine open the DB connection and let the subroutines assume it
> is already open when they are called. (Have had some bad experiences with
> web pages that open and close DB's way too many times and cause really
> excessive load).
> As the subroutines are in a seperate lib file being called by require
> "./lib/" the $dbc variable cannot be seen by the routine if strict is
> used, but is fine if strict is not used. This is needed as there are a
> number of different scripts calling the common subroutines.
> Is there a way to define global variables and keep using strict? Have I
> missed something else ?

	Hmm.  I've been doing something similar except without the web part.  
I just defined a package variable (global to the package) which opened the 

	You don't say what additional technologies if any you're using, but if
it's web pages, then maybe you're using mod_perl, and if that's the case, then
there's some info about this kind of thing in the performance tuning section
of the mod_perl documentation.


| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayland at | I am                           |

Version 3.12
GCS d+ s:- a- C++>++++$ U++ P++ L++ E- W+++ N+ w>--- V- Y+>++ 
PGP->++ R !tv b++ DI++++ D+ G e++>++++ h! y-

More information about the Melbourne-pm mailing list