Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

use require and loading modules
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.

Report this thread to moderator Post Follow-up to this message
Old Post
buildmorelines
09-29-04 02:27 AM


Re: use require and loading modules
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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-29-04 02:27 AM


Re: use require and loading modules
bulk88@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?

Report this thread to moderator Post Follow-up to this message
Old Post
buildmorelines
09-29-04 04:02 PM


Re: use require and loading modules
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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-29-04 04:02 PM


Re: use require and loading modules
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

Report this thread to moderator Post Follow-up to this message
Old Post
Shawn Corey
09-29-04 04:02 PM


Re: use require and loading modules

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.


Report this thread to moderator Post Follow-up to this message
Old Post
Brian McCauley
10-01-04 01:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:42 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.