Hi, I am fairly new to perl (but not C) and am trying out some code. In a nutshell, it spits out the old 'Internal Server' error page. To make matters worse, I cannot check my server logs for more information. The code is supposed to be a simple counter, and I am trying some interesting type switching (no 'atoi()' or 'itoa()' functions that I am aware of). If someone could find the error I would be very grateful :) ...
#!/usr/bin/perl ######################################## ## INITIALIZE CGI ###################### ######################################## use lib qw(.); use CGI; use CGI::Carp qw(fatalsToBrowser); $cgi = new CGI; ######################################## ## MAIN ################################ ######################################## $DATAFILE = "hitcount-sendtoevery.txt"; $WEBPAGE_INITIALIZE = "<html><body bgcolor=\"#000000\" text=\"#ffffff\ +" link=\"#ffffff\" vlink=\"#ffffff\" alink=\"#ffffff\"><font face=\"A +rial\" color=\"#000000\"><center><table border=\"0\" width=\"400\" ce +llspacing=\"20\" cellpadding=\"20\"><tr><td><center><h5>"; $WEBPAGE_SHUTDOWN = "</h5></center></td></tr></table></center></font>< +/body></html>"; $val = 0; open(RECORD, "$DATAFILE") or error_page_exit("Could not open datafile" +); $val = $_; close(RECORD); $val++; open(RECORD, ">$DATAFILE") or error_page_exit("Could not open datafile +"); print(RECORD, $val); close(RECORD); print $cgi->header(); print $WEBPAGE_INITIALIZE; print "Your download will begin automatically...(not working yet!)"; print $WEBPAGE_SHUTDOWN; ######################################## ## EXIT ################################ ######################################## exit; ######################################## ## ERROR ############################### ######################################## sub error_page_exit { print $cgi->header(); print $WEBPAGE_INITIALIZE; print "ERROR - Reason: "; print shift; print $WEBPAGE_SHUTDOWN; exit; } ######################################## ## END OF FILE ######################### ########################################
... thanks again, reaction

Edited by Chady -- retitled from 'noob question'


In reply to CGI script makes Internal Server-error by reaction

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.