Forking is the creation of a new process that's a copy of the current process. Changing a variable in one process doesn't change similarly named variables in other processes.
You modify the child's process's %hash, but you're dumping the parent's process's %hash.
P::FM does provide a mechanism for passing data back to the parent process. It's documented under the heading "RETRIEVING DATASTRUCTURES from child processes".
use Data::Dumper qw( Dumper );
use Parallel::ForkManager qw( );
use constant MAX_WORKERS => 200;
my %hash;
my $pm = Parallel::ForkManager->new(MAX_WORKERS);
$pm->run_on_finish(sub {
my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $result_ref) = @_;
my $IP = $ident;
warn("Child $IP killed by signal $exit_signal"), return if $exit_signal;
warn("Child $IP exited with error $exit_code"), return if $exit_code;
warn("Child $IP encountered an unknown error"), return if !$result_ref;
$hash{$IP} = $$result_ref;
});
for my $IP (keys %$values) {
my $pid = $pm->start($IP) and next;
$pm->finish(0, \$self->getData($IP));
}
$pm->wait_all_children();
print(Dumper(\%hash));