I'm wondering if there is a better (safer, faster, etc.) way of dynamically loading a class by it's name, and then invoking the constructor (using the class name). The key is we don't want to have to say "use BAREWORD_CLASS", but want to get some of the same benefits. Here's what I'm doing now:
my ($class, $arg1, $arg2) = @_;
eval "require $class";
print "Load error for class='$class': $@\n";
my $new_obj = $class->new ($arg1, $arg2);
Is this inefficient? Will it compile the perl class every time it hits the require statement?