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: <%-{-{-{-<
|