Hit Counter

Why would an experienced programmer be proud of a hit counter? After all, the only thing this program does is tell you that you are visitor number 24847. The reason is that there is no datafile; this program is a variant of a Quine. Each time it executes, it prints out the number of previous executions, then overwrites its own sourcecode with a new (slightly modified) version of itself.

counter1.txt or counter2.txt (1.2KB)
Download the Perl script. The first version works on systems where CGI scripts can overwrite themselves without taking special measures. The second includes an extra 'chmod' step for systems with heavier security. After the first successful execution, the scripts rewrite themselves into their working format.
Last modified: 23 November 2000