From the docs for the start
method:
This method does the fork. It returns the pid of the child process for the parent, and 0 for the child process.
As it happens, the fork
function does the same, which is why start
mirrors it.
The parent may need the child PID to control the child – sending signals and stuff – but the child knows its own PID via the $$
variable:
foreach my $data (@all_data) {
$pm->start and next;
print "Hello $$\n";
$pm->finish;
}
Example output:
Hello 22215
Hello 22218
Hello 22219
Hello 22217
Hello 22220
Hello 22216