If you're trying to debug a CGI script, one thing you can do is run the program from the command line. If you have instatiantiated a new CGI object
$query = new CGI;
It will ask for name/value pairs and you enter them one per line such as
name=Irving color=Blue money=happiness
You would enter those for whatever value your script expects, if any. When you're done, or if you are not passing any name/value pairs to the script, hit control-D and the script will run. If you have a lot of name/value pairs, you can toss them into a file and use
$query = new CGI(FILENAME);
That will read the information from the file without you needing to retype it every time.

If you haven't used "new CGI" the program will run without asking for name/value pairs.

This may seem like a bit more work up front, but I find that it allows for a lot of quick and dirty debugging from the command line. You may also want to look into the Perl debugger. Once you get used to it, it's a wonderful tool.

Final note: not to be redundant, but the others are right when they say to never create a CGI script without -wT and use strict. A good source for initial information is a brief overview of Safe Scripting in Perl that can be found at perl.com. Also, on a Linux or Unix system with perl documentation installed, enter the following at the command line: <CODE> perldoc perlsec </


In reply to RE: Opening a file error by Ovid
in thread Opening a file error by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.