flamey has asked for the wisdom of the Perl Monks concerning the following question:

I'm very new to Perl web development, and it's the first time I'm trying CGI::Application. But I'm having a lot of trouble finding the problem whenever the application isn't working.

I added use CGI::Carp qw(fatalsToBrowser); in the main script for the development time, but information it gives me is not very helpful.

How do you debug CGI::Application scripts?

Replies are listed 'Best First'.
Re: CGI:Application: how to debug?
by ww (Archbishop) on Jan 18, 2010 at 15:14 UTC
    Have you debugged it before running it as CGI?

    perl -c filename and perl -d filename are your friends.

    If you've already tried those, perhaps some additional information (or code) is in order.

Re: CGI:Application: how to debug?
by marto (Cardinal) on Jan 18, 2010 at 15:17 UTC
Re: CGI::Application: how to debug?
by SilasTheMonk (Chaplain) on Jan 18, 2010 at 16:30 UTC
    All of the answers I have seen are good. I think I have a few things to add.
    • Production code should run under taint mode, but when doing command line debugging you usually have to turn it off because the debugger has a tendency to crash.
    • Debugging form processing has additional complications. I think there is nothing here that does not apply to CGI in general. If a form seems to misbehave make sure you are setting all the parameters even if to the empty string. Also have you turned on the debug mode in CGI?
    • Also if you ever end up debugging through DataFormValidator you'll need to know about the overload module first, as the Results class overloads certain contexts to a boolean value. This means you must deference the object as hash before you can inspect it.
Re: CGI::Application: how to debug?
by wfsp (Abbot) on Jan 20, 2010 at 14:54 UTC