| File: | tests/hilo |
| Coverage: | 93.8% |
| 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 |
3
|
471
|
my $number = @ARGV ? shift : int rand(100) + 1;
|
||
| 13 |
3
|
53
|
my $guess = -1;
|
||
| 14 |
|
||||
| 15 |
3
5
|
170
851
|
while ($guess != $number) {
|
||
| 16 |
5
|
104
|
print "What is your guess: ";
|
||
| 17 |
5
|
7378468
|
$guess = <STDIN>;
|
||
| 18 |
5
|
454
|
if ($guess > $number) {
|
||
| 19 |
1
|
545
|
print "Too high\n";
|
||
| 20 |
} elsif ($guess < $number) {
|
||||
| 21 |
1
|
150
|
print "Too low\n";
|
||
| 22 |
} else {
|
||||
| 23 |
3
|
487
|
print "Right!\n";
|
||
| 24 |
}
|
||||
| 25 |
}
|