Hi,
I was perusing the Panther book (advanced perl programming), and noticed that, in a particular example, the author does the following:
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,
dora c
I was perusing the Panther book (advanced perl programming), and noticed that, in a particular example, the author does the following:
Code:
package Object Template;
require Exporter;
@ObjectTemplate::ISA = qw(Exporter);
@ObjectTemplate::EXPORT = qw(attributes);
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"
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,
dora c