http://qs321.pair.com?node_id=552233
Category: Web Stuff
Author/Contact Info GreyFox greyfox@30gigs.com greyfox@hacktek.net
Description: This is a simple hit counter I threw together for my website. Nothing fancy, it just
#!/usr/bin/perl -w
#Simple hit counter

#To include in a webpage (HTML), put <!--#exec cmd="PATHTOCGISCRIPT.cg
+i"--> in the document
#Replacing PATHTOCGISCRIPT with the url to the CGI script (this script
+).
#For PHP, within the <?php and ?> tags, include "virtual("PATHTOCGISCR
+IPT.cgi");"
#without the quotes.  Also, you need to create
#a file named hits.txt for the script to access.  It can
#be blank

#Script copyright 2006 GreyFox of hacktek.net 


#VARIABLES

$file = "hits.txt";

#READING

open (COUNT,"<$file") or die "Counter error 1";
$hits = <COUNT>;
close COUNT;

#INCREMENTING

$hits++;

#CONTENT

print "Hits: $hits";

#SAVING

open (COUNT,">$file") or die "Counter error 2";
print COUNT $hits;
close COUNT;