Hi all,
I want to send my Dancer2 TT page as an email and continue to generate a normal web response.
This forking discussion seems like an excellent approach.
I have:
1. Created a fork in 'hook before_layout_render' (based on a 'var want_email = 1;').
2. The parent continues to serve the webpage (as normal, after undef'ing want_email), the grandchild sends the email (in 'hook after_layout_render')
(I'm doing this in before_layout_render so I can change the layout (app->template_engine->layout('email');) to a lighter, more email-friendly layout)
An additional benefit of this approach is that the email is sent asynchronously, since Gmail-dispatched emails seem to take 2-3s to send.
This all works well and I am grateful for this discussion and Andy's example code, but I am unclear about the guard, per below.
I understand what it is intended to do, but if I put:
my $guard = guard { info "I'm dying"; POSIX::_exit(0); };
in my code, the code immediately prints the "I'm dying" and exits.