in reply to Re: How do I select a random key from a hash?
in thread How do I select a random key from a hash?
But you are computing the keys twice, and that's expensive for large hashes. Perhaps this instead:
do { my @k = keys %hash; $k[rand @k] }
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Answer: How do I select a random key from a hash?
by ysth (Canon) on Nov 04, 2003 at 10:09 UTC |