http://www.perlmonks.org?node_id=553110


in reply to Re^2: random number with range
in thread random number with range

won't disagree, but first thing that came to mind for similar situations where the technique is useful, like the ubiquitous password generator:
my @chars = ( 'A' .. 'Z', 0 .. 9); my $pw = join('',@chars[ map { rand @chars } ( 1 .. 12 ) ]);