Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

  1. use A; is compiled.
  2. use A; is executed. (BEGIN blocks are executed as soon as they are compiled.)
    1. require A; is executed.
      1. If A hasn't previously been loaded,
        1. A is loaded and compiled.
          1. ...
          2. require Exporter; is compiled.
          3. @ISA = qw(Exporter); is compiled.
          4. @EXPORT = qw( abc ); is compiled.
          5. ...
        2. A is executed.
          1. ...
          2. require Exporter; is executed.
            1. If Exporter hasn't previously been loaded,
              1. Exporter is loaded and compiled.
                1. ...
                2. sub import { ... } is compiled.
                3. ...
              2. Exporter is executed.
                1. ...
          3. @ISA = qw(Exporter); is executed.
          4. @EXPORT = qw( abc ); is executed.
          5. ...
    2. 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.)


In reply to Re: loading modules using 'use' by ikegami
in thread loading modules using 'use' by angshuman

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



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found