I get 500 errors all the time when I am writing cgi but after soem debuging i always figure it out. but with this one i can find no explination to the error and have looked it over and over and over. if you could hel it would be greatly apiciated. so here it is
!/usr/bin/perl
use CGI;
my $query = CGI->new();
my $name = $query->cookie('username');
my $name2 = param('nametext');
open FILE, "user/$name" or die "Error: $!\n";
my %data = ();
while ( my $line = <FILE> ) {
chomp $line;
my ($key, $value) = split(/\s*:\s*/, $line);
$data{$key} = $value;
}
close FILE;
open FILE2, "user/$name2" or die "Error: $!\n";
my %data2 = ();
while ( my $line2 = <FILE> ) {
chomp $line2;
my ($key, $value) = split(/\s*:\s*/, $line2);
$data2{$key} = $value;
}
close FILE2;
print "content-type: text/html\n\n";
print "<html>";
print "<head><title>!BATTLE!</title></head>";
print "<body bgcolor=black text=silver>";
print "<p>And The Feirce battle begins!";
sub genRand {
my $startNumber = shift();
my $endNumber = shift();
my $randNumber = int($startNumber + rand() * ($endNumber - $startNumbe
+r));
return $randNumber;
};
$hp=$data{htp};
$minatt=$data{minatt};
$maxatt=$data{maxatt};
$hp2=$data2{htp};
$minatt2=$data2{minatt};
$maxatt2=$data2{maxatt};
while ($hp > 0 and $hp2 > 0)
{
$att=genRand($minatt,$maxatt);
print "<p> you deal ",$att," damage! he has ";
$hp2=$hp2-$att;
print $hp2," HP remaining";
$att2=genRand($minatt2,$maxatt2);
print "<p> he deals ",$att2," Damage!";
$hp=$hp-$att2;
print " you have ",$hp," HP remaining";
if ($hp < 1) {print "<p>$name2 Wins!!\n";}
elsif ($hp2 < 1) {print "<p> You Win!!\n"; }; };