Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messagebuildmorelines 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
Post Follow-up to this messagebulk88@hotmail.com (buildmorelines) wrote in message news:<ee659c69.0409281710.38e1f2e4@pos ting.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?
Post Follow-up to this messagebuildmorelines 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
Post Follow-up to this messageGunnar 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
Post Follow-up to this messageGunnar 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.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.