Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Is local a declaration?by dsb (Chaplain) |
on Apr 10, 2002 at 15:58 UTC ( [id://158050]=note: print w/replies, xml ) | Need Help?? |
When you are using the strict pragma, Perl is, in a sense, enforcing the use of fully qualified variable names. All variables belong to a package, if even only the main package. So when you use strict and initialize a variable with <text>my</text>, essentially Perl is identifying that variable as part of the current package(like $package::var - NOTE - WHen no package is explicitly declared, the package is 'main').
So: UPDATE: I originally posted that my $var was equivalent to $Test::var. That is incorrect however, I've since learned that lexical variables are not package variables at all. I offer as proof: 'local' on the other hand does not actually initialize variables, and certainly does nothing to fully qualify the variable name with a package.
As far as the error goes: Global symbol "$var" requires explicit package name at - line 3. When Perl says 'explicit package name', technically you could fix your problem my preceding all of your variables with the name of the current package instead of using 'my', but you'd have to do that every time you use the variable...blech! But just so you understand:
Amel - f.k.a. - kel
In Section
Seekers of Perl Wisdom
|
|