http://www.perlmonks.org?node_id=798674


in reply to Dynamically load all modules from a directory

use needs a bare word so it isn't suitable for the kind of dynamic loading you want to do. require can be used instead but you must use the file name as is (don't strip the final .pm) like this:

foreach my $mod(@files){ my($filename, $directories, $suffix) = fileparse($mod); # don't do this - we need the actual filename!!! # $filename=~s/\.pm//gx; require $filename; }

There is a nice example in the perl documentation for require as well.

Best, beth