Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Perl] Improved Guessing Game
07-25-2010, 11:52 AM
Post: #1
[Perl] Improved Guessing Game
Code:
#!/usr/bin/perl -w
$Count = 0;
$Think = int(rand 10);
#Creates an psuedo-random integer between 0-10

do{
print "Pick a Number:\t";
chomp($guess=<stdin>);

if ($guess > $Think){
    print "Too High!\n";      
    }

if($guess < $Think){
    print "Too Low!\n";
    }
    $Count++;
}while($guess != $Think);
print "Correct!\nIt Took You $Count Tries To Get It!\n";

Just added a DoWhile Loop and A Counter.

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
07-28-2010, 12:35 AM
Post: #2
RE: [Perl] Improved Guessing Game
Very good and interesting, almost the same that i made in Delphi (GUI) :
http://www.pro9ramming.com/guess-the-num...-t-77.html
Great job !!!

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
07-28-2010, 02:08 AM
Post: #3
RE: [Perl] Improved Guessing Game
(07-28-2010 12:35 AM)drdebcol Wrote:  Very good and interesting, almost the same that i made in Delphi (GUI) :
http://www.pro9ramming.com/guess-the-num...-t-77.html
Great job !!!

Thanks. I may try to do this in Perl/TK. What are your opinions? Should I go for it, or not.

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: