in reply to import() when require-d module name is variable
The package name is not mymodule.pm, so of course the import() call fails. Convert the file path to a package name:
(my $package_name = $file_path) =~ s{/}{::}g; $package_name =~ s/\.pm//;
Then you can call import() on it.
|
|---|