$pm->run_on_finish(sub { my ($pid, $exit_code, $ident) = @_; my ($action, $host) = $ident =~ /^(.*?) on (.*)/s; printf "run_on_finish: %s (pid: %s exited with code: %s\n", $ident, $pid, $exit_code; insert_into_db(\$dbh, $host, $action, $exit_code); });