in reply to Re^2: Is 'use vars' really obsolete?
in thread Is 'use vars' really obsolete?
our has lexical scope.
Try the statementc:\@Work\Perl\monks>perl -wMstrict -le "{ package Foo; our $test = 12345; } ;; { package Bar; print 'fully qualified: ', $Foo::test; } " fully qualified: 12345
print 'unqualified: ', $test;
in package Bar.
BTW: Perl 5.14 introduced the neater (IMHO) package NAMESPACE BLOCK syntax, so the code above could now look like
package Foo { our $test = 12345; } package Bar { print 'fully qualified: ', $Foo::test; }
Update: Note that package also has lexical scope!
Give a man a fish: <%-{-{-{-<
|
---|
In Section
Seekers of Perl Wisdom