File: | tests/hilo |
Coverage: | 100.0% |
Perl version: | 5.8.0 |
Platform: | solaris |
line | stmt | branch | cond | time | code |
---|---|---|---|---|---|
1 |
#!/usr/local/bin/perl -w
|
||||
2 |
|
||||
3 |
# Copyright 2003, Paul Johnson (pjcj@cpan.org)
|
||||
4 |
|
||||
5 |
# This software is free. It is licensed under the same terms as Perl itself.
|
||||
6 |
|
||||
7 |
# The latest version of this software should be available from my homepage:
|
||||
8 |
# http://www.pjcj.net
|
||||
9 |
|
||||
10 |
use strict;
|
||||
11 |
|
||||
12 |
4
|
1027
|
my $number = @ARGV ? shift : int rand(100) + 1;
|
||
13 |
4
|
71
|
my $guess = -1;
|
||
14 |
|
||||
15 |
4
11
|
228
629
|
while ($guess != $number) {
|
||
16 |
11
|
200
|
print "What is your guess: ";
|
||
17 |
11
|
49620425
|
$guess = <STDIN>;
|
||
18 |
11
|
1341
|
if ($guess > $number) {
|
||
19 |
3
|
475
|
print "Too high\n";
|
||
20 |
} elsif ($guess < $number) {
|
||||
21 |
4
|
571
|
print "Too low\n";
|
||
22 |
} else {
|
||||
23 |
4
|
562
|
print "Right!\n";
|
||
24 |
}
|
||||
25 |
}
|