On Wed, Nov 27, 2002 at 04:47:01PM -0700, Wayne Simmons wrote:
> "An our declaration declares a global variable that will be visible across
> its entire lexical scope, even across package boundaries. The package in
> which the variable is entered is determined at the point of the declaration,
> not at the point of use. This means the following behavior holds:
>     package Foo;
>     our $bar;           # declares $Foo::bar for rest of lexical scope
>     $bar = 20;
>     package Bar;
>     print $bar;         # prints 20"
> Am I just misunderstanding this? Or is it because these two packages are in
> the same file?  This would seem to me "Visible ... across package
> boundaries" would mean that you would declare it in one package and see it
> in another....

It is because it is in the same block. Try this for comparison:

-- CUT --
package Foo;

{
    our $bar;
    $bar = 20;
}

package Bar;

{
    print $bar;
}
-- CUT --

our() continues to the end of the block, just as my() does.

mark

-- 
[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to