perl and cgi help
Posted by: road_kill
Posted on: 2006-09-11 00:22:00
I am new to this stuff and I am trying to count the number of downloads each of the games on my site gets. When someone clicks "download" they are sent to a .pl file that is supposed to open a data file, add 1 to the overal number of downloads, close the file, and then redirect them to the .zip file location.
Here is the code:
#!/usr/bin/perl
open(INF,"flash_info.dat") or dienice("Couldn't wright data to file. $!");
@flashinfo = <INF>;
close(INF);
$ENV{'QUERY_STRING'} =~ tr/ / /;
$cat = $ENV{'QUERY_STRING'};
foreach $i (@flashinfo) {
chomp($i);
($fname,$user,$plays,$dloads,$type,$location,$wi,$hi,$dload,$zip) = split(/|/,$i);
if ($fname eq $cat) {
$stuff = $i;
}
}
foreach $i ($stuff) {
chomp($i);
($fname,$user,$plays,$dloads,$type,$location,$wi,$hi,$dload,$zip) = split(/|/,$i);
}
open(INF,">flash_info.dat") or dienice("Couldn't wright data to file. $!");
flock(INF,2);
seek(INF,0,0);
$dloads_add = $dloads + 1;
foreach $i (@flashinfo) {
chomp($i);
if ($i eq $stuff) {
print INF "$fname|$user|$plays|$dloads_add|$type|$location|$wi|$hi|$dload|$zipn";
} else {
print INF "$in";
}
}
close(INF);
print "Location:$zipnn";
Every time I upload it ther is a Internal Server Error and The script won't run. I am sure I am missing something very obvious.
Any help will be greatly appreciated.
Brad Campbell
woochoochinchilla.com