From: | Michelle Murrain <mpm(at)norwottuck(dot)com> |
---|---|
To: | Randall Perry <rgp(at)systame(dot)com>, <pgsql-general(at)postgresql(dot)org>, <macperl(at)perl(dot)org> |
Subject: | Re: Perl Scope problem |
Date: | 2001-05-03 12:39:18 |
Message-ID: | 01050308391800.01195@chicago.murrain.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)norwottuck(dot)com
http://www.norwottuck.com
From | Date | Subject | |
---|---|---|---|
Next Message | Renaud Thonnart | 2001-05-03 12:39:20 | Re: Time to insert |
Previous Message | Jason | 2001-05-03 12:06:25 | psql with PHP question |