Click to See Complete Forum and Search --> : Counter help


ReganSMC
04-16-2007, 01:34 AM
I made this counter to count the number of people who use my link but the counter will only show 1. I would appreciate any advice anyone can give me...

File Edit Options Buffers Tools Help
#!/opt/csw/bin/perl -w

# ex1greeting.cgi
# This CGI program returns a greeting to the client

use CGI ":standard";

print header;
print start_html("Shows greetings to whoever clicks on the links");

#Sets the seed for rand
srand;

#Computes a random integer 0-4
$number = int(rand 5);

@greetings= ('Yo!', 'Aloha!', 'Bonjour!', 'Hello!', 'Hola!');
print ("$greetings[$number] \n");

br;

$countfile = "cgicount";

$count = `cat $countfile`;
chop($count);
$count = $count + 1;
open(INF,">$countfile");
print INF "$count\n";
close(INF);

print "<font size=-1>You are visitor number $count.</font><p>\n";

print end_html;

Thank you.

CyCo
04-16-2007, 09:20 PM
The script runs as intended on a "UNIX" box. If you are running this on a Windows box, you'll need to open the file, read the file, close the file, in lieu of using the `cat` command.