[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] need clarification on 'my' and 'use vars'



On Thu, Sep 02, 1999 at 10:35:54AM -0400, Paul Corr wrote:
> 
> My guess is that using 'my' with its limited scope, declares the variables
> as file-level scope variables. The advantage is that they would be
> available to subs in that script but not to a script calling this script. 
> The 'use vars' line looks like it makes the variables globally available.
> Correct? Is there an advantage to the latter? For example, connecting to
> databases, working with sockets, etc.
> 

That is correct.

One situation that calls for use vars is using one of the Getopt modules,
where code in the Getopt::Whatever package needs access to variables in
the main package.

Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org