in reply to array problem

Another approach is to shuffle a set of indices using a Schwartzian transform, and then use a subset of the randomized indices to select a subset of the images.
my @indices = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, rand()] } 0 .. $#arr; my @subset = @arr[@indices[0..$number_to_show - 1]];