2
启动额外perl模块中定义的子例程的线程的正确语法是什么?Perl线程 - 从模块调用子程序(pm)
perl程序:
use strict;
use warnings;
use forks;
require testModule;
# before solution - thanks ysth!
# testModule->main will not work!
#my $thr1 = threads->new(\&testModule->main, "inputA_1", "inputB_1");
#my $thr2 = threads->new(\&testModule->main, "inputA_2", "inputB_2");
# solved
#my $thr1 = threads->new(\&testModule::main, "inputA_1", "inputB_1");
#my $thr2 = threads->new(\&testModule::main, "inputA_2", "inputB_2");
my @output1 = $thr1->join;
my @output2 = $thr2->join;
Perl模块,testModule.pm:
package testModule;
sub main{
my @input = @_;
#some code
return ($output1, $output2)
}
什么是确切的系统调用 testModule->主要?
在此先感谢!
我向溶液添加到Perl的代码 - 谢谢你! –