Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: random index in array - no duplicatesby crazyinsomniac (Prior) |
on Jun 07, 2002 at 00:38 UTC ( [id://172401]=note: print w/replies, xml ) | Need Help?? |
An option is to use splice. It's probably not the most efficient (you can always benchmark to make sure), but otherwise you can't get away with a single pass (at least not using rand, there probably is a perl module to only spit out unique random values, but its destined to be less efficient than just keeping track yourself).
In Section
Seekers of Perl Wisdom
|
|