in reply to Re^2: Regarding Declaring Variables
in thread Regarding Declaring Variables

my $target = 1 + int rand (20); # number 1 - 20

would be more conventional for generating a random integer. Note that your version generates a number in the range 0 - 9 which may not be what some people would expect.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^4: Regarding Declaring Variables
by ysth (Canon) on Nov 18, 2005 at 12:36 UTC
    No, %f rounds, so it generates a number in the range 0-10, but 0 and 10 have only half the chance of occuring that other numbers do.