[Wellington-pm] A question about scopes

Cliff Pratt enkidu at cliffp.com
Mon Mar 20 13:22:12 PST 2006


Say I have a Package and a PERL script. If the package uses a variable 
$foo, and so does the script, I should be able to access the script's 
version of $foo by $main::foo in the package. Am I correct?

If $bar is defined in a sub in the package (eg my $bar), its scope is 
just the sub, isn't it? How do I make the scope "global" to the package 
so that any sub can find it? (I know "global" is not technically correct 
here) Define it outside any subs in the package? Does code outside a sub 
in a package ever get executed?

If I make $bar "global" to the package, is there a clever way of 
avoiding qualifying it all the time to distinguish it from the script's 
version of $bar?

Cheers,

Cliff

-- 

http://barzoomian.blogspot.com


More information about the Wellington-pm mailing list