| File: | tests/hilo | 
| Coverage: | 68.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 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        153
                    
                     | my $number = @ARGV ? shift : int rand(100) + 1; | ||
| 13 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        18
                    
                     | my $guess = -1; | ||
| 14 |  | ||||
| 15 | 
                    
                    
                        1
                    
                     
                    
                    
                        1
                    
                     | 
                    
                    
                        57
                    
                     
                    
                    
                        91
                    
                     | while ($guess != $number) { | ||
| 16 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        26
                    
                     |     print "What is your guess: "; | ||
| 17 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        846603
                    
                     |     $guess = <STDIN>; | ||
| 18 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        105
                    
                     |     if ($guess > $number) { | ||
| 19 | 
                    
                    
                        0
                    
                     |         print "Too high\n"; | |||
| 20 |     } elsif ($guess < $number) { | ||||
| 21 | 
                    
                    
                        0
                    
                     |         print "Too low\n"; | |||
| 22 |     } else { | ||||
| 23 | 
                    
                    
                        1
                    
                     | 
                    
                    
                        162
                    
                     |         print "Right!\n"; | ||
| 24 |     } | ||||
| 25 | } |