是否可以在 Perl 运行时加载模块?我尝试了以下方法,但没有奏效。我在程序的某处写了以下内容:
require some_module;
import some_module ("some_func");
some_func;
最佳答案
Foo.pm
package Foo;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT = qw(bar);
sub bar { print "bar(@_)\n" }
1;
script.pl use strict;
use warnings;
require Foo;
Foo->import('bar');
bar(1, 22, 333);
关于perl - 如何在 Perl 中在运行时加载模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2855207/