Welcome, Guest. Please Login or Register
  We've upgraded to YaBB 2!
  HomeHelpSearchLogin Forgot Password Register  
 
Page Index Toggle Pages: 1
Send Topic Print
Hits counter (Read 400 times)
Help Me With Perl
YaBB Administrator
*****
Offline


I love Perl and YaBB!

Posts: 157
The Land of Perl / YaBB
Hits counter
Aug 6th, 2009 at 10:14pm
 
Here is a working hits counter in perl

Code:

$inFile2 = "/path/to/file/";


if(-e $inFile2)
{
#read from the file
open out2, "< $inFile2" or die "Can't open $inFile2 : $!";
$count = <out2>;
close out2;
unlink($inFile2);
#add 1 to value
$count++;
open OUT2, "+> $inFile2" or die "Can't open $inFile2 : $!";
printf OUT2 $count;
close OUT2;
chmod(0666, $inFile2); # to chmod file when created
print qq~ <br>Ad Has Been Viewed: $count Times<br>~;
}
else
{
open OUT2, "+> $inFile2" or die "Can't open $inFile2 : $!";
$count=1;
printf OUT2 $count;
close OUT2;
chmod(0666, $inFile2); # to chmod file when created
print qq~ <br>Ad Has Been Viewed: $count Times<br>~;
}

Back to top
 

helpmewithperl Administrator.
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print