Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 imbibing at the Monastery: (4)
As of 2014-11-23 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (131 votes), past polls