Thanks ! I thought that they were both loaded all the time....due to it
being a compile time thing.

My reason for asking is that I have code that is called through a dynamic
dispatch. The main loop basically waits and sits for a message from another
machine to dispatch a job. The message contains the script to load and the
subroutine to execute. Lately however, I have started to use and build more
and more modules and wanted to track some of these issues down, before I end
up doing something foolish.

As can be expected, a program that does jobs for other machines has had more
and more 'bits' tacked on to the sides and I just want to make sure I keep
the train on the track. The main code can theoretically execute any
message - if the script and sub exist....so I'm looking ahead for
'gotcha's..

Thanks,
Neil

----- Original Message -----
From: "Merrill Cornish" <[EMAIL PROTECTED]>
To: "Neil" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, January 01, 2003 3:59 PM
Subject: selective use of modules


Neil,

A use statement is processed at compile time while the if statement is
processed at run time.  Therefore, you cannot conditionalize a use with an
if.  In your example, both Trapper and Logger are being loaded all the
time.

If you want to conditionalize the loading of modules, then either use
require, which is processed at run time, or put the if/use statements in a
BEGIN{} block, which will be processed at compile time BEFORE the rest of
the program is compiled.

Notice, however, that require does not import modules variables like use
does, but you are fully qualifying the module names so it shouldn't make a
different to you.

Merrill
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to