Whiteknight
01-29-2004, 12:45 AM
Okay, I'm working on learning some perl, and I am trying to make a CGI counter for my website. I am trying to make it as simple as possible. I got the SSI working perfectly, but the counter always claims there is only 1 hit, the counter never increments. I'm new to perl, so some of the syntax (like the binds) are a little confusing. can anybody see an obvious problem I've made here?
#!/usr/bin/perl
print "Content-Type: text/HTML\n\n";
$page = "$ENV{'DOCUMENT_URI'}";
$data = "/var/www/html/data";
if ($page =~ /\/&/)
{
chop($page);
}
$page =~ s/[^\w]/_/g;
if (-e "$data$page")
{
open(FILE,">$data$page");
$count = <FILE>;
close(FILE);
}
else
{
$count = "0";
open(FILE,">$data$page");
print FILE $count";
close(FILE);
}
$count += 1;
print "$count";
open(FILE, ">$data$page");
print FILE "$count";
close(FILE);
#!/usr/bin/perl
print "Content-Type: text/HTML\n\n";
$page = "$ENV{'DOCUMENT_URI'}";
$data = "/var/www/html/data";
if ($page =~ /\/&/)
{
chop($page);
}
$page =~ s/[^\w]/_/g;
if (-e "$data$page")
{
open(FILE,">$data$page");
$count = <FILE>;
close(FILE);
}
else
{
$count = "0";
open(FILE,">$data$page");
print FILE $count";
close(FILE);
}
$count += 1;
print "$count";
open(FILE, ">$data$page");
print FILE "$count";
close(FILE);