in reply to Loading Modules At Run-Time With Interpolation
Your function looks correct to me. Is it something you are just postulating here, or did you try it and get some sort of error message or condition?
(my $pm = $module) =~ s.::./.g; $pm .= '.pm'; eval { require $pm }
Shouldn't matter if $module is hardcoded or built up from pieces. I actually use this type of idea already in some of my code where the base package is settable in one location, making specifying sub-packages much easier, as well as changing the root-level package.
|
|---|