Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Nov 2001 17:35:28 -0000
From:      "Lance Keay" <lancetek@hotmail.com>
To:        "Andre` Niel Cameron" <AndreC@Axxs.net>, "free bsd" <freebsd-questions@FreeBSD.ORG>, <cgi-list@jann.com>
Cc:        <beginners-cgi@perl.org>
Subject:   Re: Quick question
Message-ID:  <OE41tNyKRBMz2vN9EP6000085ae@hotmail.com>
References:  <034601c173cb$8edfee00$a50410ac@olmct.net>

next in thread | previous in thread | raw e-mail | index | archive | help
this will give you a random number of 0 or 1.  Just substitue the 1 for the
number range you want.
Note:  I have found that the lowest and highest numbers do not appear to
have the same randomness weighting as the middle range, probably due to the
sprintf rounding, so add two to the range you want and disregard the lowest
and highest returned.

#!usr/bin/perl

srand;

for($x=0; $x<20; $x++)
{
 $holdRand=sprintf("%.0f", rand(1));
 print"\n$holdRand";
}


----- Original Message -----
From: "Andre` Niel Cameron" <AndreC@Axxs.net>
To: "free bsd" <freebsd-questions@FreeBSD.ORG>; <cgi-list@jann.com>
Cc: <beginners-cgi@perl.org>
Sent: Friday, November 23, 2001 3:04 AM
Subject: Quick question


> Hi,
>
> Anyone know how to get a whole random number in perl?
>
> rand(18) always gives decimals I need just like 12 or 7 anyone know?
>
> Regards,
> Andre` C.
> Technical Support
> ԿԬ
> --------------------------------------------------------------------------
--
> -
> Visit our support manual at http://supportmanual.com/
>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
>
>

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OE41tNyKRBMz2vN9EP6000085ae>