[Israel.pm] order on hash
E.Dan at F5.com
Wed Mar 30 08:10:52 PDT 2011
Don’t rely on the order, as explicitly stated in the perldoc for “keys”:
$ perldoc -f keys
Returns a list consisting of all the keys of the named hash.
(In scalar context, returns the number of keys.)
The keys are returned in an apparently random order. The
actual random order is subject to change in future versions of
perl, but it is guaranteed to be the same order as either the
"values" or "each" function produces (given that the hash has
not been modified). Since Perl 5.8.1 the ordering is different
even between different runs of Perl for security reasons (see
"Algorithmic Complexity Attacks" in perlsec).
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Gaal Yahas
Sent: Wednesday, March 30, 2011 17:06
To: Perl in Israel
Subject: Re: [Israel.pm] order on hash
Don't rely on the order.
On Wed, Mar 30, 2011 at 4:59 PM, Chanan Berler <bc.other at gmail.com<mailto:bc.other at gmail.com>> wrote:
I have 2 different Linux machines (same OS version / same Perl version):
(assuming there are least 200 keys/values - same keys/values on both machines)
I wonder if i do
foreach (keys $myHash)
will it print the same on both machines ? will the order be exactly the same ?
friend of mine, says it's same B-Tree algorithm on both machines,
since it's same Perl version.
What do you think ?
---- Chanan Berler ----
Perl mailing list
Perl at perl.org.il<mailto:Perl at perl.org.il>
Gaal Yahas <gaal at forum2.org<mailto:gaal at forum2.org>>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Perl