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"; }; };

In reply to 500 server error with no explenation by JBowes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.