爲什麼下面的代碼:爲什麼這個fork循環沒有按預期工作?
#!/usr/bin/perl
use strict;
use warnings;
use Parallel::ForkManager;
my $pm = new Parallel::ForkManager(5);
my @all_data = ('a','b','c','d','e','f');
foreach my $data (@all_data) {
# Forks and returns the pid for the child:
my $pid = $pm->start and next;
print "Hello $pid\n";
$pm->finish; # Terminates the child process
}
$pm->wait_all_children;
打印:
Hello 0
Hello 0
Hello 0
Hello 0
Hello 0
我新的Perl和我試圖趕上在Perl
多處理
我在Windows上使用'#!/ usr/bin/perl'.Just注意到... – Cratylus