in reply to Selecting random records from an array

If you have 5.8 or later installed the following should work:
use strict; use warnings; use List::Util 'shuffle'; my @big = (qw(u n s o r t e d)); my @shuffle = (shuffle(@big))[0 .. $#big*.75]; print join "|",@shuffle;
if not you might want to glance at 'perldoc -q shuffle' for other ways to do this.

-enlil

Replies are listed 'Best First'.
Re^2: Selecting random records from an array (worse)
by tye (Sage) on Jun 03, 2003 at 23:37 UTC

    It's too bad that they didn't bother to implement shuffle() so that it could efficiently stop early. But "worse is better", no?

    (tye)Re: Random Picks shows how. Other notes in that thread show alternate solutions.

                    - tye