#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use Math::Random; my @array = qw( cat dog shark frog chimp seahorse ); my @permuted_index = random_permuted_index( scalar(@array) ); print "Here is your entire set:\n"; print Dumper @array; print "Here is a random pick of two:\n"; print Dumper @array[ splice( @permuted_index, 0, 2 ) ]; print "And another two (unique from 1st two):\n"; print Dumper @array[ splice( @permuted_index, 0, 2 ) ]; print "And the final two:\n"; print Dumper @array[ splice( @permuted_index, 0, 2 ) ];