|go ahead... be a heretic
Interactive debug of CGI.pm script with requests from a browserby chrestomanci (Priest)
|on Jul 06, 2011 at 15:47 UTC
chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:
Greetings wise brothers
I am a fan of the perl debugger, the interactive command line one. Some people have fingers trained for Vim shortcuts, mine are trained to type x 3 $varable or b <line> $foo =~ m/bar/. My prefered method of writing perl is write a skeleton that passes perl -c and then debug it by testing out constructs in the debugger, and pasting what works into my editor.
With that in mind how should I debug a cgi script that uses CGI.pm while viewing and interacting with it using a normal web browser?
In the past I have worked on a Catalyst application, where I could run perl -d script/myapp_server.pl set breakpoints on areas of interest, and then point my browser at http://localhost:3000. When my code hit a breakpoint I could debug normaly, but at the same time I can see results as the end user does in a web browser.
I know that with CGI, you can run the script on the command line and debug it that way. The problem with that approach is that it is hard if you want to pass in a lot of form parameters, and the output you get is raw HTML.
I also know that you can do printf style debugging by running the script on a webserver, and causing it to embed lots of trace output into the page it generates.
I have also found that the EPIC IDE (a plugin for Eclipse) will let you debug cgi scripts using a built in web server. This is what I want, but without the GUI. The EPIC debugger is slow, unstable, and not as powerfull as the command line.
In short is there a perl web server out there that will run cgi scripts in the same process as the server, so that I can just run perl webServer.pl /path/to/web-root and have it execute those cgi scripts using the same perl process, while also serving up static content so that I can browse the site I am working on with a normal browser.