How do i debug cgi programs where the html contains a post form ?
If it contains a get form it is easy because i can run perl -d from
the command line.
In this case i have a very large form with many variables and it is a
post form.
How can i debug it ?
I made a google search and found answers like printing the environment
variables and then run it like a get command with perl -d but this is
a bit tedious.
Is there a "best practice" for this type of problem ?
Thanks in advance,
David
--------
use CGI;
use Data::Dumper;
my $query= new CGI();
print $query->header();
print Data::Dumper->Dump([$query]);
----------
This should give you all information into your browser.
-Sopan Shewale
(http://sopanshewale.blogspot.com)
http://search.cpan.org/dist/CGI.pm/CGI.pm#DEBUGGING
CGI has a -debug mode that should allow you to emulate POST input
from
the command line. I haven't tried it, so I have no idea what it does
about the CONTENT_LENGTH stuff. The alternative would be to set
CONTENT_LENGTH and open a file of your POST data on STDIN.
Does it have file upload fields?
> How can i debug it ?
What kind of bugs are you looking for?
> I made a google search and found answers like printing the environment
> variables and then run it like a get command with perl -d but this is
> a bit tedious.
> Is there a "best practice" for this type of problem ?
I find the best practice is not making bugs in the first place. :)
I also often add code to the CGI to process secret debugging parameter,
which turns on strategically placed extra print or warn statements.
warn "Now I'm doing $foo" if $cgi->url_param('debug');
If you really want to debug under -d, then you can run the program using
$cgi->save($file_handle) to save the query and then perl -d script.cgi <
saved_query_file
(this won't work with file upload fields, as the file contents are not
saved.)
Where the script use CGI has been changed to something like:
use CGI qw(-debug);
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
Thank you very much
On Nov 20, 6:27 pm, xhos...@gmail.com wrote:
I have now another problem. The $cgi->save($file_handle) does not save
cookie data. How it is possible to work with it when using also cookie
data ?