| From: | "Jeff Duffy" <jeff(at)alanne(dot)com> |
|---|---|
| To: | will trillich <will(at)serensoft(dot)com>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Perl Scope problem |
| Date: | 2001-05-04 13:22:28 |
| Message-ID: | 200105041722.f44HMnA69142@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Justin Clift | 2001-05-04 13:32:12 | Re: DB Getting Slower and Slower and Slower.... |
| Previous Message | Vince Vielhaber | 2001-05-04 13:18:52 | Re: Invoices |