<?xml version="1.0" encoding="windows-1252"?>
<node id="868629" title="Re: getting random number 8 times never the same" created="2010-10-31 14:12:13" updated="2010-10-31 14:12:13">
<type id="11">
note</type>
<author id="436161">
davies</author>
<data>
<field name="doctext">
This is the standard "pack of cards" algorithm that I mentioned in [id://846685], misunderstanding [BrowserUk]'s question. Changing the code for your case would give:
&lt;c&gt;
use strict;
use warnings;

my $nRepeats = 1;
my @sSet = (4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
my $nLength = 8;

my @sAll;
for (1..$nRepeats) {
    push (@sAll, @sSet);
}

if ($nLength - 1 &gt; $#sAll) {die "Don't be silly"}

my $sString;
for (1..$nLength) {
    my $i = int(rand(@sAll));
    $sString .= $sAll[$i];
    $sAll[$i] = $sAll[-1];
    pop(@sAll);
}

print "$sString \n";
&lt;/c&gt;
I haven't tested this variation, but I tested the original.
&lt;br&gt;&lt;br&gt;
Regards,&lt;br&gt;&lt;br&gt;
John Davies</field>
<field name="root_node">
868601</field>
<field name="parent_node">
868601</field>
</data>
</node>
