JBowes has asked for the wisdom of the Perl Monks concerning the following question:
!/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"; }; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 500 server error with no explenation
by wog (Curate) on Jul 14, 2001 at 08:43 UTC | |
|
Re: 500 server error with no explenation
by synapse0 (Pilgrim) on Jul 14, 2001 at 08:35 UTC | |
|
Re: 500 server error with no explenation
by jepri (Parson) on Jul 14, 2001 at 15:31 UTC | |
|
Re: 500 server error with no explenation
by Zaxo (Archbishop) on Jul 14, 2001 at 08:26 UTC | |
by JBowes (Novice) on Jul 14, 2001 at 08:30 UTC | |
|
Re: 500 server error with no explenation
by LD2 (Curate) on Jul 14, 2001 at 08:38 UTC | |
|
Re: 500 server error with no explenation
by eejack (Hermit) on Jul 14, 2001 at 08:43 UTC | |
|
Re: 500 server error with no explenation
by Cobo (Scribe) on Jul 14, 2001 at 08:27 UTC | |
|
Re: 500 server error with no explenation
by Cobo (Scribe) on Jul 14, 2001 at 09:45 UTC | |
|
Re: 500 server error with no explenation
by JBowes (Novice) on Jul 14, 2001 at 08:59 UTC | |
by Zaxo (Archbishop) on Jul 14, 2001 at 09:24 UTC |