Home > Archive > PERL Miscellaneous > September 2004 > use require and loading modules
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
use require and loading modules
|
|
| buildmorelines 2004-09-28, 9:27 pm |
| As I understand, if I load a module with "use" it will be parsed
imidiatly on/read during compiled/eats up initial start-up time, if I
use "require" it is loaded when perl reaches the require statement?
I am trying to load a module, but I want to save time on start up, so
I want to load the module much later on in the program, and its not
always required.
| |
| Gunnar Hjalmarsson 2004-09-28, 9:27 pm |
| buildmorelines wrote:
> As I understand, if I load a module with "use" it will be parsed
> imidiatly on/read during compiled/eats up initial start-up time, if
> I use "require" it is loaded when perl reaches the require
> statement?
>
> I am trying to load a module, but I want to save time on start up,
> so I want to load the module much later on in the program, and its
> not always required.
?? Then change your code, for god's sake.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
| |
| buildmorelines 2004-09-29, 11:02 am |
| bulk88@hotmail.com (buildmorelines) wrote in message news:<ee659c69.0409281710.38e1f2e4@posting.google.com>...
> As I understand, if I load a module with "use" it will be parsed
> imidiatly on/read during compiled/eats up initial start-up time, if I
> use "require" it is loaded when perl reaches the require statement?
>
> I am trying to load a module, but I want to save time on start up, so
> I want to load the module much later on in the program, and its not
> always required.
I didnt have enough cola :(
What I was asking is, is there any way to load modules after the
initial compilation, as needed/on the fly/dynamically, so I wont be
loading code that will not get used?
As I understood, if I uses "use" to do it, the module will be parsed
and compiled when the program is run for the first time. I dont want
the module to be parsed and compiled when the program is run for the
first time, I want the module to be paresed and compiled when I say
its ok. how would I do this in Perl?
| |
| Gunnar Hjalmarsson 2004-09-29, 11:02 am |
| buildmorelines wrote:
> is there any way to load modules after the initial compilation, as
> needed/on the fly/dynamically, so I wont be loading code that will
> not get used?
require MyModule;
does just that, i.e. the module gets loaded only if and when that
statement is executed.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
| |
| Shawn Corey 2004-09-29, 11:02 am |
| Gunnar Hjalmarsson wrote:
> buildmorelines wrote:
>
>
>
> require MyModule;
>
> does just that, i.e. the module gets loaded only if and when that
> statement is executed.
>
See perldoc perlmod.
use MyModule;
is equivalent to
BEGIN{ require MyModule; import MyModule; }
and
use MyModule @LIST;
is
BEGIN{ require MyModule; import MyModule @LIST; }
--- Shawn
| |
| Brian McCauley 2004-09-30, 8:57 pm |
|
Gunnar Hjalmarsson wrote:
> buildmorelines wrote:
>
>
>
> require MyModule;
>
> does just that, i.e. the module gets loaded only if and when that
> statement is executed.
I think the OP is really looking for autouse.
|
|
|
|
|