use strict;
Timothy S. Nelson
wayland at smartchat.net.au
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/auth.pl" 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
database.
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 smartchat.net.au | I am |
---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK----
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-
-----END GEEK CODE BLOCK-----
More information about the Melbourne-pm
mailing list