![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
Re: How to use Plack InteractiveDebuggerby sundialsvc4 (Abbot) |
on Jun 19, 2015 at 11:28 UTC ( #1131130=note: print w/replies, xml ) | Need Help?? |
Okay, let me put my name on the following suggestions, and try my best to make them positive ones: Yes, there are debuggers for Plack, as for every other type of [Perl ...] application, but I have generally found them to be of limited usefulness. In fact, I rarely use debuggers at all. Plack (PSGI) applications are actually much easier to debug in general, e.g. compared to mod_perl, because you can cleanly separate them from the environment in which they are normally run, and instead run them in a functionally-equivalent environment that is much easier to debug. In the case of Plack, that would start with the plackup command, but also with quite a number of prove-compatible testing frameworks. A compatible HTTP server runs right at your own command-line, or within the test framework. Or, a tester simply sends a request-object to your script and evaluates the response-object that it returns. Unlike mod_perl, PSGI applications are not embedded into their environment, but are simply call-and-response remote procedure call (RPC) handlers who run a certain number of requests until they commit hara-kiri and are promptly reborn. Not to get into any hint of mod_perl bashing, I have re-engineered several “embedded apps” to instead use the PSGI technique (and not just in the Perl language), and each time found that debugging became very simple and that some fairly intractable bugs were found almost immediately after the conversion. For most debugging purposes, I simply do a lot of print STDERR calls, which show-up right at my terminal window while running plackup on the command line. I then accompany that with some very-conventional (prove ...) test suites to thoroughly exercise the code in order to flush out the more subtle problems.
In Section
Seekers of Perl Wisdom
|
|