in reply to Re: Variable access across packages?
in thread Variable access across packages?

Qualifying is a good idea, but not necessary with our
use strict; use warnings; package B; our $foo = 3; package main; print "foo is >$foo<\n"; __END__ foo is >3<

as opposed to use vars:

use strict; use warnings; package B; use vars qw($foo); $foo = 3; package main; print "foo is >$foo<\n"; __END__ Global symbol "$foo" requires explicit package name at - line 10. Execution of - aborted due to compilation errors.

our creates a lexically scoped alias (file scoped, in this case) of a variable which is visible through package boundaries. So, $foo in the first example is an alias for $B::foo, but it is visible in package main, too (but still refers to the SCALAR slot in the $B::foo typeglob.

Consider:

use strict; use warnings; { package B; our $foo = 3; } package main; print "foo is >$foo<\n"; __END__ Global symbol "$foo" requires explicit package name at - line 10. Execution of - aborted due to compilation errors.

IMHO the "(obsolete)" note in vars NAME section is plain wrong.

;-)

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}