Re: Perl Scope problem
| От | Jeff Duffy |
|---|---|
| Тема | Re: Perl Scope problem |
| Дата | |
| Msg-id | 200105041722.f44HMnA69142@postgresql.org обсуждение исходный текст |
| Ответ на | Re: Perl Scope problem (will trillich <will@serensoft.com>) |
| Список | pgsql-general |
On Thu, 3 May 2001 11:12:22 -0500, will trillich alluded:
> On Thu, May 03, 2001 at 08:39:18AM -0400, Michelle Murrain wrote:
> "use vars" takes a list of package globals that you'd like
> shortcuts for. instead of having to say 'my::package::name::var'
> every time you can just say $var instead.
Yes, but that (as you mention) still leaves the question of how code that
looks like:
use strict;
$cust_data = {};
even compiles, since he should have gotten a
'Global symbol "$cust_data" requires explicit package name..'
compile-time error.
As noted, the the vars pragma is one way around the issue. If you're using
perl 5.6.0 or higher, you can also use the 'our' declaration, which creates a
lexically (not package) scoped global variable, which is very useful for
creating globals you don't want to keep around for the length of the program.
Jeff
В списке pgsql-general по дате отправления: