Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Interactive Command Line Form Parameter Debugging

by skyknight (Hermit)
on Jul 25, 2003 at 17:46 UTC ( #277925=note: print w/ replies, xml ) Need Help??


in reply to CGI Help Guide

Oft times you'll invoke a CGI script, and while the script will in fact execute, it doesn't quite do what you were expecting. Ascertaining the nature of the problem can prove spectacularly frustrating when you have as many degrees of separation as you do in the scenario of invoking the script indirectly via a web browser. You type something into your browser, it sends a request to the server, the server invokes the script, takes back its output, and sends it back to the browser. There may even be additional intermediary steps that obscure the problem.

Being able to cut both the web browser and web server out of the picture, thus isolating the script, can be quite useful. This will enable you to see the pure, raw output of your script, including the HTTP headers, as well as give you all of the output of your script, even in the event of a crash... far more useful than just seeing "INTERNAL SERVER ERROR" and only being able to ascertain the direct cause of the script crash, as opposed to seeing all output that preceded the crash. Of course, to get the full picture you need to be able to send in the same form parameters that you were previously doing through the request originating from the browser.

To do this, you'll want to instantiate a CGI object with a file handle opened to a file that contains field/value pairs, or with STDIN and type in the values when you run the script.

use CGI; open(FILE, "<data.txt") or die "gah!"; my $query = CGI->new(FILE); ...

Where data.txt contains stuff like...

foo=bar baz=biz

This paradigm will aid in detection of the problem, potentially exposing previously hidden issues, as well as greatly expedite the run/debug/tweak cycle.


Comment on Interactive Command Line Form Parameter Debugging
Select or Download Code
Re: Interactive Command Line Form Parameter Debugging
by dragonchild (Archbishop) on Jul 25, 2003 at 17:51 UTC
    I can also see this useful for doing Test::More harnesses for CGI scripts. Excellent pointer! ++!

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-10-21 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls