分类: PERL
2016-11-01 23:25:21
猜数字游戏
1 #/usr/bin/perl -w
2
3 $im_thinking_of=int(rand 10);
4 print "Pick a number:";
5 $guess=;
6 chomp $guess;
7
8 if ($guess > $im_thinking_of ) {
9 print "Your answer is too high\n";
10 }
11 elsif ($guess < $im_thinking_of) {
12 print "Your answer is too low\n";
13 }
14 else {
15 print "Congratulations ! You got the right number\n";
16 }