如何在Perl中运行时加载模块?
发布时间:2020-12-15 21:58:59 所属栏目:大数据 来源:网络整理
导读:是否可以在运行时在Perl中加载模块?我尝试了以下,但它没有用.我在程序中的某处写了以下内容: require some_module;import some_module ("some_func");some_func; 解决方法 Foo.pm package Foo;use strict;use warnings;use base qw(Exporter);our @EXPORT
|
是否可以在运行时在Perl中加载模块?我尝试了以下,但它没有用.我在程序中的某处写了以下内容:
require some_module;
import some_module ("some_func");
some_func;
解决方法
Foo.pm
package Foo;
use strict;
use warnings;
use base qw(Exporter);
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);
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
