in reply to Parallel::ForkManager problem
The call to $pm->start creates a new process with it's own memory address space, variables are not shared between processes. So once you have 10 processes started you have 11 versions of the hash %result in memory, each of them addressable only from the process it belongs to. The one you access outside the loop belongs to the parent process and is never modified.
If you want to use a shared variable you may want to consider using threads instead of processes. Alternatively, use one of the forms of interprocess communication described in perldoc perlipc or search CPAN for "IPC" or "shared".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parallel::ForkManager problem
by salva (Canon) on Mar 28, 2006 at 10:49 UTC | |
by tirwhan (Abbot) on Mar 28, 2006 at 10:58 UTC |