http://qs1969.pair.com?node_id=1007725


in reply to Idiom to return 0 or random number of array elements

my @subset = @array[0 .. int rand(1 + @array)-1];
If the second parameter for the .. operator is lower than the first parameter, then you'll get no items.

BTW this will not return a random number of random elements. Instead it'll return the first N elements where N is a random number. If you want random elements, you could shuffle the array first.