Don’t rely on the order, as explicitly stated in the perldoc for “keys”:
$ perldoc -f keys
keys HASH
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: [email protected] [mailto:[email protected]] 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
<[email protected]<mailto:[email protected]>> wrote:
Hello All,
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)
{
print $_=$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 ?
thanks
Chanan
--
===================
---- Chanan Berler ----
===================
_______________________________________________
Perl mailing list
[email protected]<mailto:[email protected]>
http://mail.perl.org.il/mailman/listinfo/perl
--
Gaal Yahas <[email protected]<mailto:[email protected]>>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl