
Cure
User
Apr 21, 2000, 1:16 PM
Post #3 of 3
(253 views)
|
|
Re: How can i use a moudle only when i need it
[In reply to]
|
Can't Post
|
|
Hi * "use" is evaluated at compile time. * "eval {}" compiles the block at compile time. eval 'use Package'; which while being useful from the perspective of deferring the use until runtime, also fails to do the import until runtime, so prototypes and bareword-subroutines will fail. As long as you're going that far, Like this: if ($some_condition) { require Package; } and then use the full path to the subroutines, since the importer will not have executed. Just like "use Package ()". And notice, no tricky eval involved. And like Japhy said you can use the require function. thereby getting the whole thing. if ($some_condition) { require Package; import Package qw/.../; } Cure [This message has been edited by Cure (edited 04-21-2000).]
|