> our creates a lexical variable which is aliased to the package variable of the same name in the package where the our is located.

> our $foo;

> is the same as

> alias my $foo = $MyModule::foo;

not exactly, it's never a variable from the lexical pad - aliased or not - it's only a lexically scoped package var. (i.e. a compile time effect)

~$ perl -MO=Terse -e 'package foo; our $x; package bar;print $x+$a' LISTOP (0x820dd70) leave [1] OP (0x820e2d8) enter COP (0x820cc00) nextstate UNOP (0x820dd90) null [15] PADOP (0x820cb90) gvsv GV (0x8208700) *foo::x COP (0x820ddb0) nextstate LISTOP (0x823e218) print OP (0x8205710) pushmark BINOP (0x820df38) add [5] UNOP (0x820dd30) null [15] PADOP (0x820dcf0) gvsv GV (0x8208700) *foo::x UNOP (0x820cbb0) null [15] PADOP (0x82046c0) gvsv GV (0x820869c) *bar::a -e syntax OK

but I have to admit that "lexical variable" has an ambiguity.

Though checking in perlglossary clearly defines

lexical variable

A "variable" subject to "lexical scoping", declared by my. Often just called a "lexical". (The our declaration declares a lexically scoped name for a global variable, which is not itself a lexical variable.)

update

OTOH is aliasing in Perl always a compile time effect, so your interpretation is not really wrong regarding the effect ...

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: Je suis Charlie!


In reply to Re^4: Exporter not behaving as expected by LanX
in thread (Solved) Exporter not behaving as expected by davies

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.