为什么下面的代码:
#!/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 中的多处理