Reputation: 1971
Can Perl's shuffle be utilized such that each time it produces the outputs in the same order?
Upvotes: 5
Views: 743
Reputation: 8532
Use the srand() function always with the same seed value (123 in this case). E.g. I get:
srand()
123
$ perl -MList::Util=shuffle -E 'srand 123; say shuffle 1 .. 5' 41352
repeatable every time. Without the srand() call it differs.
Upvotes: 10