Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 142010

Generate random number in Perl


To generate a random number in Perl, e.g. 10 to 20 (inclusive)

my $max = 10;
my $min = 10;
my $random = int( rand( $max-$min +1 ) ) + $min;

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>