Re: 1, random; 2, unicode



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

.



Relevant Pages

  • 1, random; 2, unicode
    ... I need to extract a random item from an hash, does exist a function to do it? ... An implementable and not-too-much-slow flowchart? ... Excuse me if this question is OT. ...
    (perl.beginners)
  • Login and key exchange without public-key crypto?
    ... sends hash of sent random key + password; server also ... as session key for communication over symmetric encryption. ...
    (sci.crypt)
  • Re: Creation of principal without password
    ... Fariba wrote: ... You can create a principal with a random key by using the ... then extract this to a keytab, and use the keytab to authorise the user. ...
    (comp.protocols.kerberos)
  • Re: Login and key exchange without public-key crypto?
    ... Protocols like this have some value, but there are attacks. ... Eg, someone can monitor the channel, intercept the "random key" ... and hash of hash, and then spend the next week doing an ...
    (sci.crypt)