in reply to CGI script makes Internal Server-error

The short answer to your specific question (Update: in addition to what davido said!) is that open() only opens the file, it doesn't read anything in from the file; and $_ doesn't implicitly read anything; it simply contains data. The line missing from your program is
$_ = <RECORD>;
I.e.
open(RECORD, "$DATAFILE") or error_page_exit("Could not open datafile" +); $_ = <RECORD>; $val = $_; close(RECORD);
However, I would be irresponsible if I did not alert you to some other areas of potential difficulty with your code.
  1. All veteran perl hackers agree that you should use strict in your code. It closes the door on a wide range of potential bugs.
  2. You have a potential race condition, in that the update of the file content is done separately from getting the current content. You'd like any given instance of your script to get and set that value atomically, i.e. in one swoop, with no possibility of any other instance getting in there in the mean time. The way to do this requires two things:
    1. opening the file only once, for both read and write;
    2. getting an exclusive lock on the file while it's open.
    Of course, there's more to each of these, and they kind of work together anyway.
To open the file for reading and updating, do this:
open RECORD, "+< $DATAFILE"
Now attempt to get an exclusive lock. If some other process has the lock, this simply waits until the lock is available:
flock RECORD, 2; # exclusive lock
Now you can read the current value and modify it:
my $val = <RECORD>; chomp $val; $val++;
Now here's another tricky part: you need to reset the read/write pointer back to the beginning of the file before you write:
seek RECORD, 0, 0;
Now you can write the new value, and wrap up:
print RECORD "$val\n"; close RECORD; # automatically releases the lock
More detail is available in the documentation of the open() and flock() functions. And be sure to read the open() tutorial. Also, FAQ 9 has a little info on debugging CGI scripts. In addition, you might find some useful info in the Perl Debugging Tutorial. Lastly, don't forget to check the QandASection: CGI programming section of Categorized Questions and Answers to see if similar questions have been answered before.