chinaunix网友2008-10-10 11:37
#!/usr/bin/perl
use strict;
use warnings;
our ($You, $Me, $Draw) = (0,0,0);
my @options = ("rock", "paper", "scissors");
my($my_turn, $your_turn);
PrintIntro();
while(1) {
$my_turn = MyGo();
$your_turn = YourGo()-1;
print "Me: $options[$my_turn], You: $options[$your_turn] -- ";
Results($my_turn, $your_turn);
PrintScore($You, $Me, $Draw);
last unless Continue();
}
sub PrintIntro {
print "\nRock, paper, scissors\n";
print "---------------------\n\n";
print "Rock beats scissors,\n";
print "Scissors beats paper, \n";
print "Paper beats rock.\n\n";
}
sub MyGo { return int(rand(3)); }
sub YourGo {
my $Turn = 0;
print "Enter 1-rock, 2-paper, 3-scissors\n";
chomp($Turn =