in reply to
Re^3: eval "require $class" seems wrong (::)
in thread eval "require $class" seems wrong
Okay, well, so in the general case (including '::' in module names), the non-string-eval way to do it seems to be:
# turn $class name into $path
my $class = 'Some::Class';
my $path = $class;
$path =~ s/::/\//g;
$path .= '.pm';
# check if $path already loaded
if ( not exists $INC{$path} ) {
# do block eval on $path
eval { require $path };
die "Can't load $class: $@" if $@;
}
# if we make it here, we can use $class
my $obj = $class->new;