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.

Replies are listed 'Best First'.
Re^2: Dynamic Class Loading, Compilation, & Speed
by zwon (Abbot) 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.