in reply to Re^4: Add a fixed number of unique elements to hash [sample() vs. shuffle()]
in thread Add a fixed number of unique elements to hash

G'day hippo,

++ Thanks for checking that out. I ran a verbatim copy of your one-liner four times and got a different result each time; so, on the face of it, this seems to be working correctly (with v1.62 & v1.63).

I did actually sit down to run some tests yesterday; unfortunately, real-life barged in and the testing needed to take a backseat. I will get to it eventually.

I'm fairly certain that I didn't change any logic when moving from sample to shuffle. I recall only a very minor modification; probably just these two lines (off the top of my head):

#use List::Util 'sample'; use List::Util 'shuffle'; ... #my @playlist = sample $list_length, @all_files; my @playlist = (shuffle @all_files)[0 .. $list_length - 1];

I'll post more when I get to the testing. It's 11pm here now, so that won't be tonight. :-)

— Ken