/ Published in: Perl
Expand |
Embed | Plain Text
#!/usr/bin/env perl use warnings; use strict; do { run(); print "Play again? "; sub run { my $t = 0; do { do { print "Guess (1-100)?\n"; } while (!($g=~/\d+/) || $g>100 || $g<1); $t++; if ($g > $s){ print "$g is too HIGH!\n"; } elsif ($g < $s) { print "$g is too LOW!\n"; } } while ($g != $s); my $y = $t == 1 ? "y" : "ies"; print "$g is correct, YAY! It only took you $t tr$y!\n"; }
You need to login to post a comment.
