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