PDA

View Full Version : ganerating a random number???


maxrpg
03-09-2005, 07:45 PM
hi

i dont know much about cgi/perl but i need help please. im just going to keep this short :)

i have this: my $thing = 1;

but what i want to do is have $thing be a random number between 1 and 5 everytime the script executes..does anyone know how i do this please??

i think it has something to do with the rand command but i dont know how to use it :( ...you know like: my $thing = random number

can anyone help me??

thank you thank you thank you thank you

maxrpg
03-10-2005, 12:44 AM
oh nevermind i got it :thumbsup:

i feel it polite to let you know how i did it just incase anyone has the same problem i had.

I just used another variable thing called $random..and i set it like this

my $random = 5;
my $thing = int(rand($random));

then it just used the $random to give me a random number from 1 to 5 :D
theres probably another way to do it but it works for me so im happy!!

awsome!!

thanks