Dan wrote: > > how is it possible to get a random number between x and y? in know > int(rand(10)) returns an integer between 0 and 9, but how do i get it so > that i can get a random integer say between 5 and 10 inclusive?
You want a random integer from the set ( 5, 6, 7, 8, 9, 10 ). Subtract 5 from 10 will give you 5. Since you need 6 numbers add 1 to that and pass that to rand(). rand() will produce a random number in the range 0.0 - 5.9999... which converted to an integer is 0 - 5. Add 5 to the result and you will have a random integer in the range 5 - 10. my ( $x, $y ) = ( 5, 10 ); my $result = int( rand( $y - $x + 1 ) ) + $x; If you want to be sure that $y is always greater then $x: ( $x, $y ) = ( $y, $x ) if $x > $y; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]