I usually use a cleanup handler to run everything that should happen after the HTTP request has completed:
$r->push_handlers( PerlCleanupHandler => sub { print "I'm doing stuff!" } );
If you really need to make the plug, you should not do it in the usual way, because your forked process will interfere with the various resources that Apache needs, such as file descriptors and sockets, and it’s very difficult to handle all this correctly. Try Apache2 :: Instead: Subprocess .