Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do I dynamically declare a package name for

by hdp (Beadle)
on Apr 27, 2001 at 08:44 UTC ( [id://75994] : note . print w/replies, xml ) Need Help??


in reply to How do I dynamically declare a package name for

eval "use $module"; $@ and die $@; # or warn $@, etc. die seems appropriate here my $vendor = $module->new(); # ...
eval is necessary because use is normally a compile-time directive. You could get a similar effect with require and import; for your purposes, use is probably easier.

$@ is where eval puts its error messages. See perlvar for more details.

hdp.