Re: 1, random; 2, unicode
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 27 Dec 2006 11:54:22 -0800
Adriano Allora wrote:
two questions:
1) I need to extract a random item from an hash, does exist a function
to do it? A module? An implementable and not-too-much-slow flowchart?
Why not just get a list of the keys, and then choose a random key from
that list?
{untested}
my $random_key = (keys %hash)[rand(keys %hash)];
my $random_value = $hash{$random_key};
Paul Lalli
.
- Follow-Ups:
- Re: 1, random; 2, unicode
- From: nobull67@xxxxxxxxx
- Re: 1, random; 2, unicode
- References:
- 1, random; 2, unicode
- From: Adriano Allora
- 1, random; 2, unicode
- Prev by Date: 1, random; 2, unicode
- Next by Date: Re: Regular Expression and file editing.
- Previous by thread: 1, random; 2, unicode
- Next by thread: Re: 1, random; 2, unicode
- Index(es):
Relevant Pages
|
|