in reply to random elements from array - new twist
sub pick (\@) { my $array = shift; return splice @{$array}, rand @{$array}, 1; } my @array = (1..15); my @results = (); push @results, pick @array for 1..5;
This code differs from the other solution above in that it makes use of the splice function to remove and return an element from the array, thereby ensuring that when the pick function is called again, that same value cannot be returned.
perl -e 'print+unpack("N",pack("B32","00000000000000000000000111011001")),"\n"'
|
|---|