Prev Code Coverage - Tales From the Trenches Next

Hilo example

     $ cat tests/hilo
     #!/usr/local/bin/perl -w
     use strict;
     my $number = @ARGV ? shift : int rand(100) + 1;
     my $guess = -1;
     while ($guess != $number) {
         print "What is your guess: ";
         $guess = <STDIN>;
         if ($guess > $number) {
             print "Too high\n";
         } elsif ($guess < $number) {
             print "Too low\n";
         } else {
             print "Right!\n";
         }
     }


Slide 33 YAPC::Europe::2003 Copyright © 2003 Paul Johnson