Here's the gig :
Sometimes I get caught up in fixing errors in CGI scripts, and my mind opens up to the dozens and dozens of components that interact with each other to bring my customers the hot-hot CGI action they expect of me.
I think about the apache servers, the iis servers, the domino and notes servers, the linux boxes, the NT and win2000 boxes, e-mail gateways, routers and trunks, all of the scripts that I've written and that others have written and how we've improved and changed them, maybe docmenting, manybe not, and all of the possible and horrible interactions they could have. In my mind, I picture them all working like a giant wheat thresher, cutting and spinning, hulling and seperating and working at a frightening pace.
After a few moments of terrifying myself in this fashion, I start debugging.

What web server are you using?
Have you checked the logs?
Perhaps you don't have access to the web server or its logs; this is not entirely uncommon, as I understand it.

But understand that even though the script is meant to run through CGI, you still have ways of testing the script. Chief and most basic among these means is perl -c script.pl. The -c switch will not attempt to run script.pl, but simply test its syntax and return its 'compilability".

Running this against your script, I see

syntax error at C:\script.pl line 15, near "result substr"
perhaps you meant return substr $start, length $line;?

Also, please, for your own sake, add a die clause to your open line : open FILE, "user/test" || die "Can't open file! Perl says '$!'".

Talk with your web server admin and see if you can get access to the log files. If not, learn to rely on CGI's command line mode, or set up a similar server on a machine you control.


In reply to (boo) debug-fu! by boo_radley
in thread same 500 server error problem shorter question 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.