Re: Perl Scope problem - Mailing list pgsql-general

From Jeff Duffy
Subject Re: Perl Scope problem
Date
Msg-id 200105041722.f44HMnA69142@postgresql.org
Whole thread Raw
In response to Re: Perl Scope problem  (will trillich <will@serensoft.com>)
List 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 by date:

Previous
From: "Othman Laraki"
Date:
Subject: RE: RE: Can't get Postgres to use indices
Next
From: "sathya"
Date:
Subject: Technical Suggestion Pl. Clarrify.