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.

Generate random number in Perl

Answer:

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;
  1. Generate random number in Linux
  2. Generate a random number in Python
  3. How to generate random password?
  4. Generate new list using map in Perl
  5. Counting the number of pair(s) in Perl’s hash

Leave a Reply

(required)

(required)

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>