Reputation: 2199
=any
eval qq(
use $$category_r[0];
);
die $? if $?;
=cut
require "$$category_r[0].pm";
Now only require
is working for me,I don't know why the 1st one doesn't work as expected...
Even this is not working:
my $pkg = "A";
eval {
use $pkg;
};
Upvotes: 0
Views: 101
Reputation: 5308
Try Module::Load if you want to load modules on the fly.
It works for both filenames and modules. It is safer than
my $module = "strict; warn 'PWNED'";
eval "use $module";
Also, as @daxim points out, it explains what's going on.
Upvotes: 5