http://qs1969.pair.com?node_id=634438

rvosa has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

there are some situations where I need to use/require a class from a variable (say $class). The way I do that is by:
eval "require $class"; if ( $@ ) { die "Can't load $class: $@"; } my $obj = $class->new;
...or something to that effect, i.e. by using a string eval. This feels wrong (perlcritic complains about it also). What's the right way?

Thanks!