Question : cgi equivalent to the php code

Hello Experts,
I have a small php script which actually increment a counter on every hit on the page, becuase it is a php script I cannot include in a .cgi  page(perl).
Please can someone help in making a .cgi script equivalent to the below php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
?>
your help is much appreciated.
thanks
sam

Answer : cgi equivalent to the php code

#!/usr/bin/perl
@ARGV="hitcounter.txt";
$^I=".bak";
while( <> ){
   $hits = ++$_;
   print;
}
print "Content-Type: text/plain

$hits
";


Random Solutions  
 
programming4us programming4us