Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Guess A Number

by MrYoya (Monk)
on Mar 17, 2003 at 19:00 UTC ( [id://243747]=note: print w/replies, xml ) Need Help??


in reply to Guess A Number

This program looks like a good exercise to learn on. I noticed that at the beginning of the program you initialize $dbm{win} and later use $dbm{won}, resulting in an uninitialized value warning.

Another idea for improvement is to put the input in a loop and only exit the loop upon receiving the proper input. This is one way:

my $max; chomp($max = <STDIN>) while(not defined $max && $max =~ m/^[0-9]+$/); my $answer = int(rand($max))+1;

Replies are listed 'Best First'.
Re: Re: Guess A Number
by sulfericacid (Deacon) on Mar 18, 2003 at 04:32 UTC
    All these little programs are made for learning, and something like this is fun to play with so it's killing two birds with one stone, lol. Thanks for the correction of $dbm{won}, that was changed.

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://243747]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found