http://www.perlmonks.org?node_id=1199639


in reply to Re^2: Is 'use vars' really obsolete?
in thread Is 'use vars' really obsolete?

our has lexical scope.

c:\@Work\Perl\monks>perl -wMstrict -le "{ package Foo; our $test = 12345; } ;; { package Bar; print 'fully qualified: ', $Foo::test; } " fully qualified: 12345
Try the statement
    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:  <%-{-{-{-<