Guest User

Untitled

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