Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

RE: Random number

by gronkulator (Sexton)
on Jul 10, 2000 at 17:36 UTC ( #21787=note: print w/replies, xml ) Need Help??


in reply to Random number

Code to generate an unsigned random 16 bit integer:
my $randbits="";
open(URANDOM, "/dev/urandom") or die "Phooey: $!";
read(URANDOM, $randbits, 2);
close(URANDOM);
$rand=unpack("S*", $randbits);
printf("random: %d\n", $rand);
Divide by whatever to produce a random integer in a specific range.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://21787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2022-10-01 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?