use strict;

andrew at work agray at
Sun Nov 9 18:32:40 CST 2003

Rick, thanks for taking the time to reply and for your suggestions. I think
they have pointed me in the right direction. I cant quite get my head around
oop so I will be leaving that well alone for the time being, I'me sure one
of the other ways will work fine for me.


----- Original Message ----- 
From: "Rick Measham" <rickm at>
To: "andrew at work" <agray at>; <melbourne-pm at>
Sent: Monday, November 10, 2003 10:11 AM
Subject: Re: use strict;

At 09:27 +1000 2003-11-10, andrew at work wrote:
>Is there a way to define global variables and
>keep using strict? Have I missed something else ?

Global vars are a Very Bad Thing. Especially if
you want to reference them from libraries. It's
not really a library if it requires a global
variable. If your library performs common
routines with database handles, then make the dbh
the first parameter to the function:

myLibrary::doSomething( $dbh, ... )

However, if you must use 'Global Variables', then in your main file:
use vars qw/$globalvar/;
$globalvar = 'some value';

And in your library, you can just use it:
print $globalvar

Or, if your libarry contains a package, use it as:
print $main::globalvar

Once again though, global variables are a bad thing

    ( Maybe have a look at going OO, then your     )
.oO( object can contain your 'globals', including )
    ( database handles, cache objects & parameters )


More information about the Melbourne-pm mailing list