Help with a program written in perl - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Perl Programming Support (https://www.supportforums.net/forumdisplay.php?fid=31) +---- Thread: Help with a program written in perl (/showthread.php?tid=25496) |
Help with a program written in perl - Rodman42866 - 03-06-2012 The following is a program written in perl about guessing a number. I need to add a win or loss reporting feature. #!/usr/bin/perl # guessnum.plx use warnings; use strict; my $target = 12; print "Guess my number!\n"; print "Enter your guess: "; my $guess = <STDIN>; if ($target == $guess) { print "That's it! You guessed correctly!\n"; exit; } if ($guess > $target) { print "Your number is bigger than my number\n"; exit; } if ($guess < $target){ print "Your number is less than my number\n"; exit; } RE: Help with a program written in perl - AceInfinity - 03-09-2012 Code: #!/usr/bin/perl here's what I came up with, anything you don't understand just ask... I think everything here is pretty basic to look at an analyze, but in the event you don't see how something works by looking at it then just reply here. Win/Loss is basically the same principle as the # of tries loop i've added in here. |