perlquestion
Anonymous Monk
I know the common idiom of getting a random array element: <code>$array[int rand @array];</code>. I can then extend that to return a random number of elements: <code>@array[0 .. int rand @array];</code>. But I need to also sometimes get 0 elements. Is there a more succinct way than to have two statements like this? <code>my @subset = @array[0 .. int rand(1 + @array); @subset = () if @subset > @array;</code>
14