in reply to Re^3: Parallel::ForkManager run_on_finish exit code handler
in thread Parallel::ForkManager run_on_finish exit code handler

Unless the OP edited the code, his example does not have a closure.

He didn't edit anything.

sub { my ($pid, $exit_code, $ident) = @_; ... } is a closure that captures $MAX_PROCESSES, $pm, and anything else he declares there (like $stats or $dbh).

You didn't create a closure, you just refactored the code. As such, your solution still doesn't work. See Re^3: Parallel::ForkManager run_on_finish exit code handler for a description of the actual problem and a solution for it.

Replies are listed 'Best First'.