in reply to A reproducible shuffle? ("stable shuffle")

A "stable shuffle" is just an arbitrary arrangement that doesn't change. So, why not just produce one and then embed it in the script(s) that requires it. Using your example above:

C:\test>perl -MList::Util=shuffle -wle"print join ' ', shuffle 'A'..'Z +'" Q I X H L R B C F E U M A S W J P K T O V N Y D G Z

And then just c&p that into your code:

... my @arr = qw[ Q I X H L R B C F E U M A S W J P K T O V N Y D G Z ]; ...

There you have a "stable shuffle" that stays stable until you change it. Without messing around with storing it in a DB or file.

(I also find your reasoning for not using srand inexplicable, but that's been said, and this is simpler:)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: A reproducible shuffle? ("stable shuffle")
by AK108 (Friar) on Feb 04, 2008 at 17:47 UTC
    Well, it's not just one random order I need, but some arbitrary number that increases with time. Also, the items in the order could be changed or added to. Re^2: A reproducible shuffle? ("stable shuffle") explains better.

    As for wanting to keep srand() intact, I have other code that can occur in the same page load (web application) that needs a random value (or at least a good psuedorandom value).