Visitors counter
#!C:/Perl/bin/perl.exe -w
# shebang
print "Content-Type: text/html\n\n";
print "<html><head><title>Counter</title></head>\n";
print "<body>\n";
print "<table bgcolor = black><tr><td>\n";
# content header.
$FILE='count.txt'; #the file
$digits='Numbers';
open (THIS_FILE, $FILE) || (die ("Cannot open FILE file.\n"));
flock (THIS_FILE, 2) || die ("The file FILE is being written.");
$visitors= <THIS_FILE>; #the file is just a number
flock (THIS_FILE, 8);
close (THIS_FILE);
chop($visitors);
$visitors++;
open (THIS_FILE, ">$FILE") || (die ("Cannot open FILE file.\n"));
flock (THIS_FILE, 2) || die ("The file FILE is being written.");
print THIS_FILE ("$visitors ");
flock (THIS_FILE, 8);
close (THIS_FILE);
@digit=();
print ("<font color = white size = +1>You are the : </font>");
for ($i=0;$i<length($visitors);$i++) {
$digit[$i]=substr($visitors,$i,1);
print ("<IMG SRC=\"$digits/$digit[$i].gif\" valign=\"center\"> ");
}
print ("<font color = white size = +1> th visitor of this page. </font>");
print "</td></tr></table>\n";
print "</body></html>\n";
|