This is not so much a limitation of Parallel::ForkManager as the general limit of parallel code. fork spawns a new process that is a copy of the existing one. It has its own memory space, and everything that changes between a child and a parent is ... well, changed.
Threading has the same problem.
There is a rather large chapter on how to work with interprocess communication - perlipc
Parallel::ForkManager , in particular, has several mechanisms for returning data to the parent process. Personally - I really disagree with this, because while it is working, it is also trying to be a more general solution to the problem.
I would rather think about how to use channels to pass information back to the parent process.
use strict; use warnings; use Data::Dumper; use Parallel::ForkManager; use IO::Pipe; my $pm = Parallel::ForkManager->new(2); for ( 1 .. 4 ) { my $pipe = IO::Pipe->new(); my $pid = $pm->start; if ($pid) {
source share