G'day ghosh123,
In the use documentation, you'll see:
It is exactly equivalent to
BEGIN { require Module; Module->import( LIST ); }
except that Module must be a bareword. The importation can be made conditional by using the if module.
So, if you had to use require, you could still get the compile time checks with:
BEGIN { require Module; }
However, reading a bit further down the use documentation, you'll see that this is exactly equivalent to
use Module ();
So, unless you're unable to specify a bareword for Module (see this post of mine from a few days ago for an example), or you have a particular need to load Module at runtime (e.g. your point #4 scenario [although see below]), there's really no reason not to use use.
Finally, regarding the points you made:
-
Correct.
-
Correct.
-
The "control is passed to that file at run-time" part doesn't sound right at all.
If, after reading the documentation I've provided links to, you still believe this is correct, please clarify what you mean (perhaps I'm missing your intent).
-
In that particular scenario, you'd probably need to weigh up whether you want to avoid an initialisation delay at the expense of (conditionally) having the same delay at some point in the middle of the program.
There are situations where modules are loaded conditionally, using require, that have nothing to do with initialisation delays (as an example, see the File::Spec source code).
-
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.
|