Re: Perl Scope problem
От | Michelle Murrain |
---|---|
Тема | Re: Perl Scope problem |
Дата | |
Msg-id | 01050308391800.01195@chicago.murrain.net обсуждение исходный текст |
Ответ на | Perl Scope problem (Randall Perry <rgp@systame.com>) |
Ответы |
Re: Perl Scope problem
|
Список | 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 по дате отправления: