use List::Util 'shuffle'; use List::MoreUtils 'minmax'; my @array = 'a' .. 'z'; my @quantities; for( 1 .. 100 ) { # --------------------This is the solution line: ----------------------------- my @selected = @{ [ shuffle @array ] }[ 0 .. int( rand @array + 1 ) - 1 ]; # ------------------------------------------------------------------------ push @quantities, my $quantity = @selected; print "@selected => ($quantity)\n"; } print "\nMin/Max elements: (", join( ',', minmax @quantities ), ")\n";