http://qs321.pair.com?node_id=210400


in reply to Re: random elements from array - new twist
in thread random elements from array - new twist

BTW shuffle() subroutine is implemented in perl module List::Util. It is probably faster than your pure Perl implementation as it is written in C.

--
Ilya Martynov, ilya@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org

  • Comment on Re: Re: random elements from array - new twist

Replies are listed 'Best First'.
Re: Re: Re: random elements from array - new twist
by fglock (Vicar) on Nov 05, 2002 at 11:52 UTC
    use List::Util qw(shuffle); @a=qw(a b g f t h y); ($a,$b,$c) = @a[(shuffle(0..$#a))[0..2]]; print " $a $b $c ";