[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [users] Re: random lines

On Tue, Jul 03, 2001 at 12:23:20AM +0200, Martin F. Krafft wrote:
> also sprach Steven Smolinski (on Mon, 02 Jul 2001 01:46:29PM -0400):
> > That algorithm is one of the purest distillations of beauty I've ever
> > seen.  :-)  Remember, the perlfaq is far more peer-reviewed than almost
> > any other source of info.
> okay, okay. i believe you. did you give me a link for that thing,
> because now i am interested.


... or ...

perldoc -q 'select a random line'

"How do I select a random line from a file?"

> still, i like the map version better simply because a permutation of
> the albums is actually what i want for a random album player, is it
> not?

Huh?  I thought you wanted one random line chosen out of several?

If you want to shuffle an array, that's a different monster.
Unsurprisingly, perlfaq4 also has an implementation of the Fisher-Yates
shuffle to answer this question:

man perlfaq4



Steven Smolinski => http://arbiter.ca/

Reply to: