Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

Re: Dynamic Class Loading, Compilation, & Speed

by cdarke (Prior)
on Mar 06, 2010 at 23:04 UTC ( #827174=note: print w/ replies, xml ) Need Help??


in reply to Dynamic Class Loading, Compilation, & Speed

Rather than using eval with a string, it is probably better to use a block. For example:

y $class = 'gash'; eval { require "$class.plm" }; die "Oops: $@" if $@; my $obj = $class->new();
It will not recompile the class each time, perl maintains %INC to record modules loaded.


Comment on Re: Dynamic Class Loading, Compilation, & Speed
Select or Download Code
Re^2: Dynamic Class Loading, Compilation, & Speed
by zwon (Monsignor) on Mar 06, 2010 at 23:14 UTC
    require "$class.plm"

    Note, that won't work if $class='My::Class', you have to replace '::' with '/'. Module::Load takes care about this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://827174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2014-04-21 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (490 votes), past polls