use strict; use feature ':5.10'; use Parallel::ForkManager; our $pm = Parallel::ForkManager->new(8); $pm -> run_on_finish ( # called BEFORE the first call to start() sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_structure_reference) = @_; # retrieve data structure from child if (defined($data_structure_reference)) { # children are not forced to send anything my $string = ${$data_structure_reference}; # child passed a string reference if ($string) { #how to process $string? }; } else { # problems occurring during storage or retrieval will throw a warning say qq|No message received from child process $pid!|; } } ); LOOP: foreach my $instance (0..100) { $pm->start and next LOOP; # do the fork my $data; foreach my $i (0..50) { push(@$data,int(rand(10)); } $pm->finish(0,\$data); # exit the child process } $pm->wait_all_children;