how to randomize List::Util::shuffle() better?

Discussion in 'Perl Misc' started by Nomen Nescio, Oct 7, 2005.

  1. Nomen Nescio

    Nomen Nescio Guest

    I want to pick three things at random from a list, so:

    use List::Util 'shuffle';

    ...

    sub pick {
    my @items = shuffle(@_);
    return join(",", @items[0,1,2]);
    }

    but every time I call this (repeatedly within the same run) with the
    same input list, I get the same three items back out.

    Is there any way to randomize shuffle more?
     
    Nomen Nescio, Oct 7, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Badass Scotsman

    Why wont this Randomize? (Classic VB Script ASP)

    Badass Scotsman, May 5, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    517
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    May 5, 2006
  2. Zaphod

    Randomize STL stack

    Zaphod, Apr 25, 2004, in forum: C++
    Replies:
    3
    Views:
    690
    Andrew Koenig
    Apr 27, 2004
  3. Jeff Moore

    Array.shuffle/Array.shuffle!

    Jeff Moore, Aug 24, 2008, in forum: Ruby
    Replies:
    6
    Views:
    156
    Alexei Broner
    Oct 9, 2008
  4. Richard Gration
    Replies:
    3
    Views:
    182
    Anno Siegel
    Nov 26, 2004
  5. Michele Dondi
    Replies:
    5
    Views:
    209
    Michele Dondi
    Jul 13, 2007
Loading...

Share This Page