in reply to Understanding why strict prevents a use of local
But as and aside regarding use vars and our declarations. I don't believe they are quite equivalent. This might be splitting hairs, but a use vars declaration gives a package variable while an our declaration gives a global disguised as a my variable. This means the scoping is lexical for our variables. The following code
would not compile under strict. $variable is out of scope by the print statement. A use vars qw($variable); line would work however.&decl(); print $variable; sub decl { our $variable = 1; }
Another implication, if you are using packages to give different name spaces in the same file, a declaration like...
might not do what you expect. For example not run under strict. The vars variable $thing1 is a package variable, not available to the main package without a $one::thing1 type address. $thing2 however, the our declaration <e>is</e> available to the main package. It's scope is the same as my so is file wide in this sample.package one; use vars qw($thing1); our $thing2; #stuff; package main; print "$thing1 and $thing2";
I didn't get this when I first started using <cod>our</code> so I just wanted to throw it there since it seems to apply to this thread.
Ira,
"So... What do all these little arrows mean?"
~unknown
|
|---|