I strongly prefer the first option. For programs that don't fit on one
screen, using lexical (my) variables makes it much easier to keep one part
of the program from interfering with the rest.
I have occasionally used global variables, but only for very specific data
sharing between modules.
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Ronald J Kimball" <[EMAIL PROTECTED]>
To: "Christine Kluka" <[EMAIL PROTECTED]>
Cc: "Neil Lunn" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, June 20, 2001 06:55
Subject: Re: DBI Connect Failure
> On Wed, Jun 20, 2001 at 03:47:31PM +0200, Christine Kluka wrote:
> > Neil,
> >
> > Thanks, I added "my" to this variable and to the array and hash
> > declarations in my "row" subroutine -- this eliminated the "not
> > imported" errors.
> >
> > Now when I execute the script I am prompted for explicit package names
> > for each instance of a scalar, array or hash. I believe that if I
> > declare the fully qualified package name where the database handler is
> > invoked, this should take care of the problem. I've tried several ways
> > of doing this, but they all fail on syntax or for more serious reasons.
>
> That's another error that means you haven't declared your variables.
>
> When you use strict 'vars', you have three options for each variable.
>
> Declare it with my:
>
> my $lexical_variable;
> $lexical_variable = 7;
> print $lexical_variable;
>
> Declare it with use vars:
>
> use vars qw/ $global_variable /;
> $global_variable = 7;
> print $global_variable;
>
> Specify the package name every time you use it:
>
> $main::global_variable = 7;
> print $main::global_variable;
>
> Most people prefer the first two options.