Greetings good monks,

While reading (and being frustrated by) the Panther book (advanced Perl Programming) I noticed the author employed the following:

package Object Template; require Exporter; @ObjectTemplate::ISA = qw(Exporter); @ObjectTemplate::EXPORT = qw(attributes);
My questions are:

1) package scope lasts until either the end of the inner-most block (if it's defined in a block) or until another package definition is encountered. Since we're pulling in package-code by requiring Exporter, what is the official end of its package scope? there are no package declarations after "require Exporter", nor are there any blocks containing the code "package Exporter" in Exporter.pm. It does have a terminating "1" - does that officially end its scope as a package in the enclosing code above? To me, that must be the case... it would seem preposterous that its package-scope would bleed into any modules that require it.

2) why are we fully-qualifying the @ISA and @EXPORT arrays here (e.g. "@ObjectTemplate::ISA" vs. "@ISA"). Is there ambiguity as to which package they would belong to, otherwise? I've seen plenty of examples in which they are not fully qualified in this way.

3) would we have suffered by use-ing Exporter vs. Require-ing it, as above? Use is a compile-time thing, I know, and also makes the products of Exporter available to us. Even though we don't need to take explicit advantage of those in the example above, are there any other reasons for actively not using "use"?

Thank you,

MatthewFrancis


In reply to packages and Exporter by MatthewFrancis

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.