Re: Random number generator

2009-04-09 Thread ANJAN PURKAYASTHA
Thank you guys. Anjan On Thu, Apr 9, 2009 at 6:59 PM, Chas. Owens wrote: > On Thu, Apr 9, 2009 at 17:34, ANJAN PURKAYASTHA > wrote: > > I need a Bernoulli random number generator which takes as inputs: a value > > for p(1) (probability of choosing a "1") and the number of trials and > > outputs

Re: Random number generator

2009-04-09 Thread Chas. Owens
On Thu, Apr 9, 2009 at 17:34, ANJAN PURKAYASTHA wrote: > I need a Bernoulli random number generator which takes as inputs: a value > for p(1) (probability of choosing a "1") and the number of trials and > outputs a series of 0s and 1s according to the model B(p(1)). > Any thoughts on which module

Re: Random number generator

2009-04-09 Thread Jim Gibson
On 4/9/09 Thu Apr 9, 2009 2:34 PM, "ANJAN PURKAYASTHA" scribbled: > I need a Bernoulli random number generator which takes as inputs: a value > for p(1) (probability of choosing a "1") and the number of trials and > outputs a series of 0s and 1s according to the model B(p(1)). > Any thoughts on

Re: random

2008-11-25 Thread Mr. Shawn H. Corey
On Tue, 2008-11-25 at 12:51 -0500, Telemachus wrote: > On Tue Nov 25 2008 @ 12:45, Telemachus wrote: > > If you want to check if you something Perl-ish > > Something clearly went wrong here. I got caught between "to check if you can > do something with Perl" and "to check something Perl-ish." Wha

Re: random

2008-11-25 Thread Telemachus
On Tue Nov 25 2008 @ 12:45, Telemachus wrote: > If you want to check if you something Perl-ish Something clearly went wrong here. I got caught between "to check if you can do something with Perl" and "to check something Perl-ish." What I sent was neither. Feh. -- To unsubscribe, e-mail: [EMAIL

Re: random

2008-11-25 Thread Telemachus
On Tue Nov 25 2008 @ 9:29, Sharan Basappa wrote: > Hi, > > Would like to know if perl has native (without using special modules) > for generating random numbers? Shawn already pointed you in the right direction, but here's a good tip. If you want to check if you something Perl-ish, try 'perldoc

Re: random

2008-11-25 Thread Mr. Shawn H. Corey
On Tue, 2008-11-25 at 21:29 +0530, Sharan Basappa wrote: > Hi, > > Would like to know if perl has native (without using special modules) > for generating random numbers? > > Regards > See `perldoc -f rand`. -- Just my 0.0002 million dollars worth, Shawn The key to success is being too

Re: Random Image and Cache problem

2007-09-03 Thread Dr.Ruud
Carl Miller schreef: > The other website would call the perl script in an tag, like so: > > http://www.my_site.com/cgi-bin/random_banner.cgi"; > width="468" height="60"> > > I've tried several perl scripts that basically work, but the problem > is always the same with all of them: the browser alw

Re: Random Image and Cache problem

2007-09-03 Thread Mumia W.
On 09/03/2007 10:06 AM, Carl Miller wrote: Thanks Gunnar and Mumia. I figured out that the problem is unique to Internet Explorer. The three other browsers I tried don't have this problem. But I can't get IE to not cache. I've tried these: print "Cache-Control: no-cache\n"; print "Pr

Re: Random Image and Cache problem

2007-09-03 Thread Tom Phoenix
On 9/3/07, Carl Miller <[EMAIL PROTECTED]> wrote: > I figured out that the problem is unique to Internet Explorer. The three > other browsers I tried don't have this problem. But I can't get IE to not > cache. > Can anyone give some insight into where the problem might be? It's in Internet Explo

Re: Random Image and Cache problem

2007-09-03 Thread Carl Miller
Thanks Gunnar and Mumia. I figured out that the problem is unique to Internet Explorer. The three other browsers I tried don't have this problem. But I can't get IE to not cache. I've tried these: print "Cache-Control: no-cache\n"; print "Pragma: no-cache\n"; # for HTTP/1.0 print "Ex

Re: Random Image and Cache problem

2007-09-02 Thread Mumia W.
On 09/02/2007 01:16 PM, Carl Miller wrote: I'm trying to setup a simple random image script to allow other websites to display random banner ads located on my server. The other website would call the perl script in an tag, like so: http://www.my_site.com/cgi-bin/random_banner.cgi"; width="468

Re: Random Image and Cache problem

2007-09-02 Thread Gunnar Hjalmarsson
Carl Miller wrote: I'm trying to setup a simple random image script to allow other websites to display random banner ads located on my server. The other website would call the perl script in an tag, like so: http://www.my_site.com/cgi-bin/random_banner.cgi"; width="468" height="60"> I've trie

Re: random #

2005-10-09 Thread Jeff 'japhy' Pinyan
On Oct 9, ZHAO, BING said: is there a single random number generator function in perl? Or do you have any idea/algorithm on how to shuffle the elements in an array? The random number generator is rand(); its documentation is here: perldoc -f rand To shuffle an array, read: perldoc -q sh

Re: random number between x and y

2003-09-20 Thread John W. Krahn
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

Re: random number between x and y

2003-09-20 Thread Daniel Staal
--On Saturday, September 20, 2003 20:58 +0100 dan <[EMAIL PROTECTED]> 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? How about: $num

Re: random number between x and y

2003-09-20 Thread George Schlossnagle
sub rand_range { my ($x, $y) = @_; return int(rand($y - $x)) + $x; } On Saturday, September 20, 2003, at 03:58 PM, 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

Re: random number between x and y

2003-09-20 Thread J Adam Latham
This should work ... #!/usr/bin/perl -w my $num = int (rand(10) +1); if ($num >= 5 and $num <= 10) { print "$num\n"; } else { print "Sorry ... \n"; } Hope that helps ... Adam On Saturday 20 September 2003 12:58 pm, dan wrote: : how is it possible to get a random number between x

Re: Random Number Question

2003-09-20 Thread Tassilo von Parseval
From: Anonymous <[EMAIL PROTECTED]> You are aware that the domain nospam.com is registered, aren't you? If you really don't want to give any email address, use example.com as domain (or any other, that truely doesn't exist). On Fri, Sep 19, 2003 at 09:08:13PM -0400 Anonymous wrote: > How do I get

Re: Random Number Question

2003-09-20 Thread Rob Dixon
Anonymous wrote: > > How do I get perl to chose a random number from a range (1-13) and > export it to a numeric variable? Any help would be appreciated. I assume you mean integers? $value = int rand(13) + 1; BTW It would be nice to give a name, rather than posting as 'Anonymous'. Rob --

Re: random sub returns same results...

2003-04-05 Thread Rob Dixon
Meriwether Lewis wrote: > Hi Gurus! > > I have the following sub which creates a random > string. Each time I call the sub in my perl > script it returns a random string which is fine. > The problem is every time I run the script the > same strings are returned. I'm running perl > 5.001 on Windows

Re: random sub returns same results...

2003-04-05 Thread Li Ngok Lam
perldoc -f srand - Original Message - From: "meriwether lewis" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, April 05, 2003 10:09 AM Subject: random sub returns same results... > Hi Gurus! > > I have the following sub which creates a random > string. Each time I call the

RE: Random numbers

2003-03-25 Thread Bob Showalter
Gaz Wilson wrote: > Hi all! > > I am having a very odd problem, which has been going on for ages: > > Many many months ago, I wrote a small program to generate a random > number based on the number of files in a directory, the aim of the > program is basically a random background generator - all

Re: Random numbers

2003-03-25 Thread Rob Dixon
Rob Anderson wrote: > Hi Guys, > > According to my bookshelf, from 5.004 onwards srand uses a seed that's > "that's reasonably difficult to guess". Prior to that, it used time(). It > does seem as if the seed it being set the as the same value each time. Could > your program be being cached some wh

Re: Random numbers

2003-03-25 Thread Rob Anderson
Hi Guys, According to my bookshelf, from 5.004 onwards srand uses a seed that's "that's reasonably difficult to guess". Prior to that, it used time(). It does seem as if the seed it being set the as the same value each time. Could your program be being cached some where? Otherwise a suggestion fo

Re: Random numbers

2003-03-25 Thread R. Joseph Newton
Stefan Johnson wrote: > I know some people may complain and say I don't know what > I'm talking about, but I read somewhere recently (while > working on a dice function for my IRC bot) that "srand" > is no longer necessary. You might try removing that line > from your code and see what errors you

Re: Random numbers

2003-03-25 Thread Rob Dixon
Stefan Johnson wrote: > I know some people may complain and say I don't know what > I'm talking about, but I read somewhere recently (while > working on a dice function for my IRC bot) that "srand" > is no longer necessary. On the contrary, I'm sure you know what you're talking about Stefan, and y

Re: Random numbers

2003-03-25 Thread Stefan Johnson
I know some people may complain and say I don't know what I'm talking about, but I read somewhere recently (while working on a dice function for my IRC bot) that "srand" is no longer necessary. You might try removing that line from your code and see what errors you get (I doubt it will fix the pro

Re: Random wierdness with large outputs

2003-03-23 Thread R. Joseph Newton
Rob Dixon wrote: > "R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi, > > > > I'm wondering if there is an issue with the random function in terms of scaling. > [snip data] > > > > Needless to say, that is a lot of . Is there any alternativcollisionse random >

Re: Random wierdness with large outputs

2003-03-23 Thread Paul Johnson
On Sun, Mar 23, 2003 at 09:30:12PM -, Rob Dixon wrote: > Careful inspection shows that each of your random numbers is exactly > divisible by 3.0517578125. Dividing your range of 10 by this > figure (magically, for those who know their powers of two) gives > 32768, showing that 'rand' is in

Re: Random wierdness with large outputs

2003-03-23 Thread Rob Dixon
"R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm wondering if there is an issue with the random function in terms of scaling. I > have been testing a merge sort, and I noticed that when my test, built by pushing rand(10) a given number of times in

Re: Random wierdness with large outputs

2003-03-23 Thread Todd Wade
"R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm wondering if there is an issue with the random function in terms of scaling. I have been testing a merge sort, and I noticed that when my test, built by pushing rand(10) a given number of times into

Re: Random access files in Perl????

2003-03-04 Thread John W. Krahn
Bob Showalter wrote: > > Luinrandir Hernsen wrote: > > Long ago in GW Basic there were sequential files and random access > > files. > > Sounds like the start of a bedtime story... :~) > > > Does perl have the latter? > > Yes. It's really a capability of the underlying operating system. > > Pe

Re: Random access files in Perl????

2003-03-04 Thread Bob Showalter
Luinrandir Hernsen wrote: > Long ago in GW Basic there were sequential files and random access > files. Sounds like the start of a bedtime story... :~) > Does perl have the latter? Yes. It's really a capability of the underlying operating system. Perl has seek(), tell(), read(), and write() fun

RE: Random access files in Perl????

2003-03-04 Thread Dan Muey
perldoc -f seek Probably open() and seek() And all their friends will be your pal then. DMuey > the file is 250 variables. each variable is 225 charecters > long. I only need to look at a 5x5 square of information (25 > charecters, 5 charecters on 5 sequential lines. I am making a > map file

RE: Random access files in Perl????

2003-03-04 Thread Dan Muey
> .--[ Dan Muey wrote (2003/03/04 at 15:04:30) ]-- > | > | > Long ago in GW Basic there were sequential files and random > | > access files. Does perl have the latter? I only to get (and > | > then put) certain info in a certain place every time. If I > | > can avoid writing

Re: Random access files in Perl????

2003-03-04 Thread Frank Wiles
.--[ Dan Muey wrote (2003/03/04 at 15:04:30) ]-- | | > Long ago in GW Basic there were sequential files and random | > access files. Does perl have the latter? I only to get (and | > then put) certain info in a certain place every time. If I | > can avoid writing the whole fil

RE: Random access files in Perl????

2003-03-04 Thread Dan Muey
> > Long ago in GW Basic there were sequential files and random > access files. Does perl have the latter? I only to get (and > then put) certain info in a certain place every time. If I > can avoid writing the whole file every time I bet my web site Every time what?? I'm not familiar with

RE: Random Access File

2003-01-22 Thread Dan Muey
> How to access and create RandomAccessFile > could u send me simple example? Use open. If you want more help give more details. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addit

RE: Random Access File

2003-01-21 Thread Beau E. Cox
Hi - > -Original Message- > From: Galbayar Dorjgotov [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 21, 2003 8:32 PM > To: [EMAIL PROTECTED] > Subject: Random Access File > > > > How to access and create RandomAccessFile > could u send me simple example? > All (most - i.e. STDIN,

Re: Random Number Generation

2003-01-15 Thread Christopher D . Lewis
On Wednesday, January 15, 2003, at 08:28 AM, Maurice O'Prey wrote: How do I extract a whole number from the rand function. int() is your friend, if you want an integer from rand. I am using rand 25000; which generates a random number with many decimal places, e.g. 16235.2587965, I need a wh

RE: Random Number Generation

2003-01-15 Thread Dylan Boudreau
int(rand 25000) Dylan -Original Message- From: Maurice O'Prey [mailto:[EMAIL PROTECTED]] Sent: January 15, 2003 10:28 AM To: [EMAIL PROTECTED] Subject: Random Number Generation Hi All How do I extract a whole number from the rand function. I am using rand 25000; which generates a ran

RE: Random Number Generation

2003-01-15 Thread Ed Christian
> -Original Message- > From: Maurice O'Prey [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 15, 2003 9:28 AM > Hi All > > How do I extract a whole number from the rand function. > > I am using rand 25000; which generates a random number with > many decimal > places, e.g. 16235.258

Re: random string

2002-11-27 Thread Mystik Gotan
d (Webmaster Insane Hosts) www.insane-hosts.net MSN: [EMAIL PROTECTED] From: [EMAIL PROTECTED] To: "Payal Rathod" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Subject: Re: random string Date: Wed, 27 Nov 2002 11:04:28 -0600 > Someone please answer this in one word. Which language do

Re: random string

2002-11-27 Thread wiggins
> Someone please answer this in one word. Which language do I start with, > Choices are C, Python, Perl? > "Can't." That is one word :-), aka there is no way to answer your question in one word. Besides you are posting on a perl list, so of course the answer is: Perl. Honestly it totally depen

Re: random string

2002-11-27 Thread Payal Rathod
On Wed, Nov 27, 2002 at 12:18:06AM +0100, Paul Johnson wrote: > > privately in a article I intend to put on web. > I will be interested to read it. I will mail the URL to the list when it is ready ;-) > I think that if you had been able to explain your situation a little > more, telling us why you

Re: random string

2002-11-26 Thread Paul Johnson
On Sat, Nov 23, 2002 at 07:46:57PM +0530, [EMAIL PROTECTED] wrote: > Hi, > > By now you will probably have worked out that this community is very > > happy to help people of any ability to improve their Perl skills, but is > > rather reluctant just to hand out ready-made solutions. This is as it >

RE: random string

2002-11-25 Thread Halkyard, Jim
ssage- From: '[EMAIL PROTECTED]' [mailto:[EMAIL PROTECTED]] Sent: 25 November 2002 17:58 To: [EMAIL PROTECTED] Subject: Re: random string > You are missing a semi-colon at the end of line 2, and remove the comma > between the filehandle and $string in line 6. Thanks it works now

Re: random string

2002-11-25 Thread '[EMAIL PROTECTED]'
> You are missing a semi-colon at the end of line 2, and remove the comma > between the filehandle and $string in line 6. Thanks it works now. > The Perl Cookbook is one of series of books on Perl published by O'Reilly. > www.oreilly.com, generally well respected and very popular. If you start Is i

RE: random string

2002-11-25 Thread Halkyard, Jim
f you start with Learning Perl you can't go far wrong IMHO. Jim -Original Message- From: '[EMAIL PROTECTED]' [mailto:[EMAIL PROTECTED]] Sent: 25 November 2002 16:58 To: [EMAIL PROTECTED] Subject: Re: random string Hi, Thanks for the mail. > Just copy-paste the followin

Re: random string

2002-11-25 Thread '[EMAIL PROTECTED]'
Hi, Thanks for the mail. > Just copy-paste the following in a file and save it with the extension .pl I am giving the script I put in my file. I have removed all comments and adjusted the lines. The script now reads, #!/usr/local/bin/perl open PASWDFILE , ">pswdfile" my @chars = ( 'a' .. 'z', 'A'

RE: random string

2002-11-25 Thread Aman Thind
Miss P > Some people say that I have to pay for writing the script. Me > ???what are such ppl doing here anyway??? we're all here to help each other out aren't we ? these ppl are requested to put their hoardings elsewhere... pay and that too for a beginner exerc

Re: random string

2002-11-23 Thread rpayal
Hi, Thanks for the mail. > perldoc -f rand > also, > perldoc perlop Thanks, I will. > If that doesn't work, try asking your professor for help. hehehehehee, I don't have any professor. I am not a student and I never was a computer student. I am just a artist in fashion designing who does Linux as a

Re: random string

2002-11-23 Thread rpayal
Hi, > By now you will probably have worked out that this community is very > happy to help people of any ability to improve their Perl skills, but is > rather reluctant just to hand out ready-made solutions. This is as it *please read the mail in full before commenting on *anything*. * Yep, but th

Re: random string

2002-11-23 Thread Paul Johnson
On Sat, Nov 23, 2002 at 08:02:00AM +0530, [EMAIL PROTECTED] wrote: > Hi, > > why would you want to use Perl in the first place? no other alternatives? > Maybe, But I am not a coder at all. > > your problem is straight forward and if you are not familiar with Perl, you > > might want to go with ano

Re: random string

2002-11-22 Thread Tanton Gibbs
To: <[EMAIL PROTECTED]> Sent: Friday, November 22, 2002 9:32 PM Subject: Re: random string > Hi, > > why would you want to use Perl in the first place? no other alternatives? > Maybe, But I am not a coder at all. > > your problem is straight forward and if you are not familiar with

Re: random string

2002-11-22 Thread rpayal
Hi, > why would you want to use Perl in the first place? no other alternatives? Maybe, But I am not a coder at all. > your problem is straight forward and if you are not familiar with Perl, you > might want to go with another language. i don't think it will be that hard > right? c/c++? java? shel

Re: random string

2002-11-22 Thread david
[EMAIL PROTECTED] wrote: > Hi, > Thanks for the mails all. > But I haven't got a sentence or even a word. > Please, I am looking for a *script* which will print a random string. > Please someone take trouble of putting the info. in a file so that I can > cut-paste it. > As, I said I know *nothing*

Re: random string

2002-11-22 Thread rpayal
Hi, Thanks for the mails all. But I haven't got a sentence or even a word. Please, I am looking for a *script* which will print a random string. Please someone take trouble of putting the info. in a file so that I can cut-paste it. As, I said I know *nothing* of perl, nothing at all so all those my

Re: random string

2002-11-22 Thread John W. Krahn
[EMAIL PROTECTED] wrote: > > Hi, Hello, > I am not at all familar to perl. I want to write a small perl script > which will print a random string of atleast 8 characters. This string I > intend to use as password for my application. > I don't know perl at all. perl is in /usr/local/bin/perl > Th

Re: random strings

2002-11-14 Thread Dave K
Another Way use strict; my @Ary = qw ( a b c d e f g h ); for(@Ary) { print; } print"\n"; fisher_yates_shuffle(\@Ary); for(@Ary) { print; } print"\n"; sub fisher_yates_shuffle { my $array = shift; my $i; for ($i = @$array; --$i; ) { my $j = int rand ($i+1); next if $i == $j;

Re: random strings

2002-11-14 Thread Frank Wiles
.--[ Tom Allison wrote (2002/11/14 at 09:45:42) ]-- | | How can create a random string, similar to MD5 hash, but with a | much smaller number of characters? Maybe 8 characters.. | `- Here is one idea: my @letters = ('a

Re: Random generator

2002-07-19 Thread Janek Schleicher
Mohammad K Jilani wrote at Wed, 17 Jul 2002 18:15:17 +0200: > How can I generate a whole number betwee 10 - 99? > Another cool way, where I don't need to think, is using the String::Random module: use String::Random qw/random_string/; print random_string "0n", [1..9]; or perhaps more readable

Re: Random generator

2002-07-18 Thread drieux
On Wednesday, July 17, 2002, at 09:29 , Nikola Janceski wrote: > you for got the int.. he said whole numbers > > my $rand_num = int(rand(90) + 10); > good point! I had forgotten to be explicit that we wanted an int... eg: my $int = 10; my $count = rand($int) + $int;

Re: Random generator

2002-07-17 Thread Jeff 'japhy' Pinyan
On Jul 17, Jilani, Mohammad K said: >How can I generate a whole number betwee 10 - 99? Well, using int(rand(10)) gives you an integer from 0 to 9. If you add 10 to it, you get an integer from 10 to 19. To get an integer from 10 to 99, you need to come up with an expression of the form X + i

RE: Random generator

2002-07-17 Thread Nikola Janceski
you for got the int.. he said whole numbers my $rand_num = int(rand(90) + 10); > -Original Message- > From: drieux [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 17, 2002 12:25 PM > To: begin begin > Subject: Re: Random generator > > > > On Wednesd

Re: Random generator

2002-07-17 Thread drieux
On Wednesday, July 17, 2002, at 09:15 , Jilani, Mohammad K wrote: > How can I generate a whole number betwee 10 - 99? > perldoc -f rand and then tweek it since rand runs from 0 you might try say my $rand_num = rand(90) + 10; ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PR

Re: Random write ?

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 10:11 , Connie Chan wrote: > LN0;T=1;C=2;B=1234567890 > LN1;T=0;C=3;B=AABBBCCC > LN2;T=0;C=4;B=0987654321 ok, some fun with creating a file for sysread/syswrite/sysseek stuff http://www.wetware.com/drieux/pbl/Sys/ReadWriteFile.txt ciao drieux --- -- To unsub

Re: Random write ?

2002-05-15 Thread Connie Chan
-- Original Message - From: "drieux" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 15, 2002 11:18 PM Subject: Re: Random write ? > > On Wednesday, May 15, 2002, at 07:21 , Connie Chan wrote: > > > Hi everybody, > > > > Is ther

Re: Random write ?

2002-05-15 Thread drieux
On Wednesday, May 15, 2002, at 07:21 , Connie Chan wrote: > Hi everybody, > > Is there any method to write a file ( text / bin ) by random ? > just like what "seek" does. where you want to start is with perldoc -f seek since you will notice a) that it exists b) tell e

RE: random word from array

2002-03-28 Thread Timothy Johnson
ch 28, 2002 3:26 AM To: [EMAIL PROTECTED] Subject: Re: random word from array "Randal L. Schwartz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > That's correct, but if you have a very very very old Perl, you'll need > to add

Re: random word from array

2002-03-28 Thread Wytch
"James Taylor" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hrm, try this: > > @tea = "Meba", "Shaun", "Mark", "Jason", "Rick", "Dan"; > srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`); > print "$tea[rand(5)]\n"; Wow - I would love to say I understand th

Re: random word from array

2002-03-28 Thread Wytch
"John W. Krahn" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Wytch wrote: <<>> > If you had warnings enabled Perl would have caught this for tou. But I would have been none the wiser still! You have to understand that I only started Perl two nights ago and

Re: random word from array

2002-03-28 Thread Wytch
"Randal L. Schwartz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > That's correct, but if you have a very very very old Perl, you'll need > to add "srand;" at the beginning of your program. Do it just once, > though. That was one of the first things I tried

Re: random word from array

2002-03-28 Thread Wytch
> The problem is not the rand(). The problem was the user didn't put > parentheses around the elements of the array assignment. > > @array = ("This", "That", "Those"); > print $array[rand @array]; Ah ha! those curly brackets have a lot to answer for lol! I can't believe it was something so

Re: random word from array

2002-03-28 Thread Wytch
"Timothy Johnson" <[EMAIL PROTECTED]> wrote in message C0FD5BECE2F0C84EAA97D7300A500D50025811D3@SMILEY">news:C0FD5BECE2F0C84EAA97D7300A500D50025811D3@SMILEY... > > The return value of rand() is a random number between 0 and the optional > argument (1 by default). > > In this case there are 6 elem

RE: random word from array

2002-03-27 Thread Jeff 'japhy' Pinyan
On Mar 27, Timothy Johnson said: >Oops. That should be $get = int(rand(5)); No. That would give you a number between 0 and 4. The problem is not the rand(). The problem was the user didn't put parentheses around the elements of the array assignment. @array = ("This", "That", "Those"); pr

Re: random word from array

2002-03-27 Thread John W. Krahn
Wytch wrote: > > I decided to write a little script to help choose who will make the tea on > our gaming night [there is always an argument!] > > I thought I was doing quite well but it seems I am picked on by the > [non]random script I wrote! It seems to default to the first word in the > array

Re: random word from array

2002-03-27 Thread Randal L. Schwartz
> "Wytch" == Wytch <[EMAIL PROTECTED]> writes: Wytch> I thought I was doing quite well but it seems I am picked on by the Wytch> [non]random script I wrote! It seems to default to the first word in the Wytch> array. Wytch> I used rand @array; Wytch> I think perhaps that I am thinking about

RE: random word from array

2002-03-27 Thread Timothy Johnson
Oops. That should be $get = int(rand(5)); -Original Message- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 4:12 PM To: 'Wytch'; [EMAIL PROTECTED] Subject: RE: random word from array The return value of rand() is a random number between

RE: random word from array

2002-03-27 Thread Timothy Johnson
The return value of rand() is a random number between 0 and the optional argument (1 by default). In this case there are 6 elements in the array, so we want a number between 0 and 5. So try this variation on your code: @tea = ("Meba", "Shaun", "Mark", "Jason", "Rick", "Dan"); $get = int(rand

Re: random word from array

2002-03-27 Thread James Taylor
Hrm, try this: @tea = "Meba", "Shaun", "Mark", "Jason", "Rick", "Dan"; srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`); print "$tea[rand(5)]\n"; On Wednesday 27 March 2002 03:25 pm, you wrote: > I decided to write a little script to help choose who will make the tea on > our gaming night [t

RE: Random sampling in perl

2002-03-22 Thread Balint, Jess
I just typed the code in the e-mail. It was part of my program. Sorry. -Original Message- From: Wagner-David [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 4:16 PM To: 'Balint, Jess'; '[EMAIL PROTECTED]' Subject: RE: Random sampling in perl If the

RE: Random sampling in perl

2002-03-22 Thread Wagner-David
If the code then change if( $i = $array[$j] ) to if( $i == $array[$j] ) otherwise you end assigning $i with the value of $array[$i]. Wags ;) -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 13:04 To: '[EMAIL PROTECTED]' S

Re: Random sampling in perl

2002-03-22 Thread Balint, Jess
Thanks for the input. The only trouble I would have with that is the file size. My files are HUGE. I don't think the admins around here would like me doing that. What I was thinking was to generate an array with a bunch of random numbers in numerical order. Then run through the file and print only

Re: Random Sampling in Perl

2002-03-18 Thread John W. Krahn
Jess Balint wrote: > > Hello all, I have a file of 3,210,008 CSV records. I need to take a random > sample of this. I tried hacking something together a while ago, but it > seemed to repeat 65,536 different records. When I need a 5mil sample, this > creates a problem. > > Here is my old code: I

Re: Random Sampling in Perl

2002-03-18 Thread Jonathan E. Paton
> Hello all, I have a file of 3,210,008 CSV > records. I need to take a random sample of > this. I tried hacking something together a > while ago, but it seemed to repeat 65,536 > different records. When I need a 5mil > sample, this creates a problem. > > Here is my old code: I know the logic > a

RE: Random Access Numbers

2002-01-17 Thread Groenwold, Harmen (ICT) (HK)
Hi, if you just want random numbers, there is a very simple function: RAND. Works like this: #!perl -w use strict; my ($varNumber); $varNumber = rand; print "Random number is: ", $varNumber,"\n"; Harmen Groenwold [EMAIL PROTECTED] -Original Message- From: Naveen Parmar [mailto:[EMAIL PR

Re: Random Access Numbers

2002-01-17 Thread Frank
On Wed, Jan 16, 2002 at 10:25:35PM +, Naveen wrote: > Is there is a built in function in Perl for generating random access #s? > > How would that function be used? ---end quoted text--- I've just google'd "Random access numbers" and there is very little there. Nothing that seems related to a

RE: Random Number Generation

2001-08-06 Thread Russell Kroboth
$num=(int(rand 35)); There is probably a more random way to do it, but this is what i know... -Original Message- From: Mark Rowlands [mailto:[EMAIL PROTECTED]] Sent: Monday, August 06, 2001 2:59 AM To: .; Beginners (E-mail) Subject: Re: Random Number Generation On Saturday 04 August

Re: Random Number Generation

2001-08-06 Thread Mark Rowlands
On Saturday 04 August 2001 18:35, . wrote: > Another thing that I notice the llama book fails to mention is random > number generation. Is this possible in Perl? (More specifically in a CGI > script.) could also look at Math::TrulyRandom or Math::Random -- To unsubscribe, e-mail: [EMAIL PROTE

Re: Random Number Generation

2001-08-05 Thread Abdulaziz Ghuloum
Thanks for the info. Aziz,,, In article <[EMAIL PROTECTED]>, "smoot" <[EMAIL PROTECTED]> wrote: >> "Abdulaziz Ghuloum" <[EMAIL PROTECTED]> said: > >> Doesn't /dev/random produce pseudo-random numbers also? What makes >> reading from it better than using perl's rand or C's rand? > > This is g

Re: Random Number Generation

2001-08-05 Thread Paul Johnson
On Sun, Aug 05, 2001 at 07:31:45AM -1000, . wrote: > > Before 5.004 you did need to seed the PRNG, but I'm not convinced that > > time|$$ was ever a really good choice. Good enough for most purposes > > though, if called only once. > > But why only once? That's the part that confusses me. I t

Re: Random Number Generation

2001-08-04 Thread smoot
> "Abdulaziz Ghuloum" <[EMAIL PROTECTED]> said: > Doesn't /dev/random produce pseudo-random numbers also? What makes > reading from it better than using perl's rand or C's rand? This is getting a bit of topic. /dev/random is seeded with supposedly random events. In Linux I believe it takes t

Re: Random Number Generation

2001-08-04 Thread Abdulaziz Ghuloum
Hello, Doesn't /dev/random produce pseudo-random numbers also? What makes reading from it better than using perl's rand or C's rand? Aziz,,, In article <[EMAIL PROTECTED]>, "smoot" <[EMAIL PROTECTED]> wrote: >> "." <[EMAIL PROTECTED]> said: > >> Another thing that I notice the llama book fa

Re: Random Number Generation

2001-08-04 Thread Mike Rodgers
"." wrote: > > Are you sure it's the llama book, not the camel? Either way, blue or pink? > - Original Message - > From: "Mike Rodgers" <[EMAIL PROTECTED]> > To: "." <[EMAIL PROTECTED]> > Sent: Saturday, August 04, 2001

Re: Random field sequence tips

2001-07-09 Thread Abdulaziz Ghuloum
Hello The easiest way to do this is using hash slices. Let me explain. my %hash = (); # creates an empty hash $hash{name} = 'Aziz';# set the name $hash{id} = 512; #set the id $hash{bdate} = '12/3/1976/'; #set the bdate or, you can do this: %hash = (name => 'Aziz', id => 5

RE: Re: Random field sequence tips

2001-07-09 Thread paul
In reply-to Michael Fowler <[EMAIL PROTECTED]> on Mon Jul 9 13:06:42 2001 >On Mon, Jul 09, 2001 at 12:26:48PM +0100, [EMAIL PROTECTED] wrote: >> I have a text file produced by another system. The fields are semi-colon >> delimited, and the first line is a list of the fields, a header record, >>

Re: Random field sequence tips

2001-07-09 Thread Michael Fowler
On Mon, Jul 09, 2001 at 12:26:48PM +0100, [EMAIL PROTECTED] wrote: > I have a text file produced by another system. The fields are semi-colon > delimited, and the first line is a list of the fields, a header record, > also semi-colon delimited. You should investigate DBD::CSV. It has options fo

Re: Random Numbers

2001-04-24 Thread Kevin Meltzer
Hi Sushil, perldoc -f rand You can also look at the Math::Random and Math::TrulyRandom modules on the CPAN. Cheers, Kevin On Tue, Apr 24, 2001 at 02:58:16PM -0700, sushil ([EMAIL PROTECTED]) spew-ed forth: > Hi , > > Is there any one who can help me make a randon numer generator > Any help wi

  1   2   >