Re: Perl Scope problem - Mailing list pgsql-general

From Michelle Murrain
Subject Re: Perl Scope problem
Date
Msg-id 01050308391800.01195@chicago.murrain.net
Whole thread Raw
In response to Perl Scope problem  (Randall Perry <rgp@systame.com>)
Responses Re: Perl Scope problem  (will trillich <will@serensoft.com>)
List pgsql-general
On Wednesday 02 May 2001 11:27 pm, Randall Perry wrote:
> I'm baffled by perl's scoping of variables. In the code below, the
> $cust_data hash ref is inited outside the while loop. It's then set in the
> while with the results of a PgSQL query.
>
> In the if-else statement $cust_data can be seen in the 'if' but not in the
> 'else' (if I try to print a value in else, $cust_data->{'customer'}, I get
> an undeclared variable error).
>
> I understand that by using 'strict' I can't use any global variables.

No, my understanding is that it forces you to define variables both local and
global. I've used this statement to declare variables I need throughout a
script using strict:

use vars qw($val $var $value $conf @var_array @val_array %fields_hash);

Michelle

------------
Michelle Murrain, Ph.D.
President
Norwottuck Technology Resources
mpm@norwottuck.com
http://www.norwottuck.com

pgsql-general by date:

Previous
From: Renaud Thonnart
Date:
Subject: Re: Time to insert
Next
From: Diana Cionoiu
Date:
Subject: troubles with postgresql 7.0.2