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. Advertisements

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:
    658
    =?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:
    785
    Andrew Koenig
    Apr 27, 2004
  3. Sweety

    own code for randomize

    Sweety, Jul 26, 2004, in forum: C Programming
    Replies:
    2
    Views:
    395
    Erik de Castro Lopo
    Jul 27, 2004
  4. ashu

    randomize character

    ashu, Oct 18, 2005, in forum: C++
    Replies:
    6
    Views:
    720
    Default User
    Oct 18, 2005
  5. Mr. x

    randomize function

    Mr. x, Sep 18, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    170
    Mr. x
    Sep 18, 2003
  6. Jeff Moore

    Array.shuffle/Array.shuffle!

    Jeff Moore, Aug 24, 2008, in forum: Ruby
    Replies:
    6
    Views:
    361
    Alexei Broner
    Oct 9, 2008
  7. Richard Gration
    Replies:
    3
    Views:
    265
    Anno Siegel
    Nov 26, 2004
  8. Michele Dondi
    Replies:
    5
    Views:
    263
    Michele Dondi
    Jul 13, 2007
Loading...