my $r = Apache->request(); my $sub = sub { # Do your post request processing here }; $r->register_cleanup($sub);