Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to Debug the CGI Codes

by McDarren (Abbot)
on Jul 10, 2006 at 06:58 UTC ( [id://560080]=note: print w/replies, xml ) Need Help??


in reply to How to Debug the CGI Codes

There are all sorts of methods you can employ for debugging CGI code - here are a couple that I often use:
use CGI::Carp qw/fatalsToBrowser/;
This will throw any errors or warnings to your browser. (Never leave this enabled in production code).

use Data::Dumper::Simple; print q(<pre>); print Dumper(%foo);
Useful for examining the contents of any data structure.
my @params = param(); print q(<pre>); for (@params) { print "$_ :: $params[$_]\n"; }
Useful to find out which CGI parameters were passed and what their values are.

Hope this helps,
Darren :)

Replies are listed 'Best First'.
Re^2: How to Debug the CGI Codes
by strat (Canon) on Jul 10, 2006 at 08:13 UTC

    For development, I even use:

    use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;

    because it also handles warnings

    Update: is wrong, see the posting from reneeb below

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      To handle warnings, you have to call the warningsToBrowser subroutine with a true argument. See documentation of CGI::Carp.
      Just a note:
      warningsToBrowser(1) must be explicitly called after printing the page header, and will output all warnings as HTML comments. It's its difference from fatalsToBrowser, which catches all fatal errors (even compile-time!) without any additional actions. The CGI::Carp documentation contains additional info.

      UPD: i haven't seen the previous reply while writing this :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://560080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-16 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found