Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.86 KB | None | 0 0
  1. chomp ( $input = <STDIN>);
  2.  
  3. if ( $input =~ /stones=([^&]+)/ ) { $stones = $1 }
  4.  
  5. $random= int(rand(20)) + 10;
  6.  
  7. if ( $input =~ /re=/ ) { $stones = $rnd; }
  8.  
  9. if ( $input =~ /take1=([^&]+)/ ) { $stones -= 1; }
  10. if ( $input =~ /take2=([^&]+)/ ) { $stones -= 2; }
  11.  
  12. if ($stones < 0 ) { $stones = 0; }
  13. if( $input eq "" ) { $stones = $random; }
  14.  
  15.  
  16.  
  17. print "<h1>Roy's Nim</h1>";
  18. print "<h2>There are $stones stones.</h2>\n";
  19.  
  20. print "<form method='post' action=''>\n";
  21. print "<input type='hidden' value='$stones' name='stones'>\n";
  22. if ( $stones > 0 ) {
  23.     print "<input type='submit' name='take1' value='Take 1'><br><br>";
  24.     if( $stones >= 2 ){ print "<input type='submit' name='take2' value='Take 2'><br><br>"; }
  25. } else {
  26.     print "<h2>You won</h2>";
  27. }
  28.    
  29. print "<input type='submit' name='re' value='Start Over'>&nbsp;";
  30. print "</form>\n";
  31. print "</html>\n";
Add Comment
Please, Sign In to add comment