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'