There's not a single compile-time. When one says "at compile-time", one means "when the containing unit (statement, block, file) is being compiled". Same goes for run time.
use A;
is basically
BEGIN {
require A;
A->import();
}
use statements and BEGIN blocks are executed as soon are they are compiled, so the following happens
- use A; is compiled.
- use A; is executed. (BEGIN blocks are executed as soon as they are compiled.)
- require A; is executed.
- If A hasn't previously been loaded,
- A is loaded and compiled.
- ...
- require Exporter; is compiled.
- @ISA = qw(Exporter); is compiled.
- @EXPORT = qw( abc ); is compiled.
- ...
- A is executed.
- ...
- require Exporter; is executed.
- If Exporter hasn't previously been loaded,
- Exporter is loaded and compiled.
- ...
- sub import { ... } is compiled.
- ...
- Exporter is executed.
- ...
- @ISA = qw(Exporter); is executed.
- @EXPORT = qw( abc ); is executed.
- ...
- A->import(); is executed.
As you can see, Exporter is loaded and its import method is compiled before your module's import is called without having to make any modifications.
(I usually use "ModA" instead of "A" because "B" is the name of an existing module.)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|