Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

28 lines
614B

  1. #!/usr/bin/perl
  2. # this is needed to avoid deadlock with the fifo
  3. STDOUT->autoflush(1);
  4. while ($command ne "bye") {
  5. # do not play more than a number of commands
  6. # if the argument -n was not passed to blackjack
  7. if ($i++ == 1234567) {
  8. print "quit\n";
  9. }
  10. # read and process the commands
  11. chomp($command = <STDIN>);
  12. if ($command eq "bet?") {
  13. print "1\n";
  14. } elsif ($command eq "insurance?") {
  15. print "no\n";
  16. } elsif (substr($command, 0, 5) eq "play?") {
  17. @tokens = split(/ /, $command);
  18. if ($tokens[1] < 12) {
  19. print "hit\n";
  20. } else {
  21. print "stand\n";
  22. }
  23. }
  24. }