Re: 1, random; 2, unicode
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 30 Dec 2006 04:06:16 -0800
nobull67@xxxxxxxxx wrote:
Paul Lalli wrote:
my $random_key = (keys %hash)[rand(keys %hash)];
my $random_value = $hash{$random_key};
How is that better than..
my $random_value = (values %hash)[rand(keys %hash)];
Because the OP asked "how to extract a random item from a hash". I
have no idea if that meant "random key" or "random value" or both.
Your method only provides the value.
Paul Lalli
.
- References:
- 1, random; 2, unicode
- From: Adriano Allora
- Re: 1, random; 2, unicode
- From: Paul Lalli
- Re: 1, random; 2, unicode
- From: nobull67@xxxxxxxxx
- 1, random; 2, unicode
- Prev by Date: Re: 1, random; 2, unicode
- Next by Date: $myfile.doc page count
- Previous by thread: Re: 1, random; 2, unicode
- Next by thread: RE: 1, random; 2, unicode
- Index(es):