# 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;
In reply to Re^4: eval "require $class" seems wrong (::)
by rvosa
in thread eval "require $class" seems wrong
by rvosa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |